Skip to content

Commit

Permalink
Merge pull request #622 from hhatto/verbose-print-for-config-paths
Browse files Browse the repository at this point in the history
add: verbose log for reading config paths
  • Loading branch information
hhatto committed Jan 25, 2022
2 parents 577774f + ef79af0 commit 5e0d5c7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
12 changes: 12 additions & 0 deletions autopep8.py
Expand Up @@ -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:
Expand All @@ -4009,6 +4011,16 @@ 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 not os.path.exists(config_file):
continue
print(
"read config path: {}".format(
os.path.join(parent, fn)
)
)
break
(parent, tail) = os.path.split(parent)

Expand Down
9 changes: 8 additions & 1 deletion test/test_autopep8.py
Expand Up @@ -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'
Expand Down

0 comments on commit 5e0d5c7

Please sign in to comment.