From ff472aa1b7ef06cae7f6a89184327fe5441acd13 Mon Sep 17 00:00:00 2001 From: Hideo Hattori Date: Mon, 24 Jan 2022 17:28:10 +0900 Subject: [PATCH 1/3] add: verbose log for config paths --- autopep8.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/autopep8.py b/autopep8.py index 42f58871..fa73a7d9 100755 --- a/autopep8.py +++ b/autopep8.py @@ -4001,6 +4001,8 @@ def read_config(args, parser): config = SafeConfigParser() try: + if args.verbose and os.path.exists(args.global_config): + print("read config path: {}".format(args.global_config)) config.read(args.global_config) if not args.ignore_local_config: @@ -4009,6 +4011,11 @@ def read_config(args, parser): while tail: if config.read([os.path.join(parent, fn) for fn in PROJECT_CONFIG]): + if args.verbose: + for fn in PROJECT_CONFIG: + config_file = os.path.join(parent, fn) + if os.path.exists(config_file): + print("read config path: {}".format(os.path.join(parent, fn))) break (parent, tail) = os.path.split(parent) From a954444b7346879b659cc8b1f965895ffa5649c7 Mon Sep 17 00:00:00 2001 From: Hideo Hattori Date: Tue, 25 Jan 2022 09:40:57 +0900 Subject: [PATCH 2/3] lint --- autopep8.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/autopep8.py b/autopep8.py index fa73a7d9..121b8f6e 100755 --- a/autopep8.py +++ b/autopep8.py @@ -4014,8 +4014,13 @@ def read_config(args, parser): if args.verbose: for fn in PROJECT_CONFIG: config_file = os.path.join(parent, fn) - if os.path.exists(config_file): - print("read config path: {}".format(os.path.join(parent, fn))) + if not os.path.exists(config_file): + continue + print( + "read config path: {}".format( + os.path.join(parent, fn) + ) + ) break (parent, tail) = os.path.split(parent) From ef79af064baa93cc74465d349f8aa8972820248e Mon Sep 17 00:00:00 2001 From: Hideo Hattori Date: Tue, 25 Jan 2022 10:14:43 +0900 Subject: [PATCH 3/3] fix test expected result --- test/test_autopep8.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/test_autopep8.py b/test/test_autopep8.py index 13cd7c4d..2e189d62 100755 --- a/test/test_autopep8.py +++ b/test/test_autopep8.py @@ -1051,7 +1051,14 @@ def test_e101_skip_innocuous(self): os.path.join(ROOT_DIR, 'test', 'e101_example.py')], stdout=PIPE, stderr=PIPE) output = [x.decode('utf-8') for x in p.communicate()][0] - self.assertEqual('', output) + setup_cfg_file = os.path.join(ROOT_DIR, "setup.cfg") + tox_ini_file = os.path.join(ROOT_DIR, "tox.ini") + expected = """\ +read config path: /dev/null +read config path: {} +read config path: {} +""".format(setup_cfg_file, tox_ini_file) + self.assertEqual(expected, output) def test_e111_short(self): line = 'class Dummy:\n\n def __init__(self):\n pass\n'