Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: verbose log for reading config paths #622

Merged
merged 3 commits into from Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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