Skip to content

Commit 0348dc6

Browse files
committed
Don't overwrite settings when no pep8 config file exists.
The pep8 module always returns a config file, even when one doesn't exists. When it doesn't, it means pep8 merely read the defaults, so don't overwrite ST's settings. Fixes issue #4.
1 parent e57b1f1 commit 0348dc6

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

linter.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,17 @@ def onError(msg):
6868
parser = get_parser()
6969
parser.error = onError
7070
pep8_options, _ = process_options([os.curdir], True, True, parser=parser)
71-
pep8_options = vars(pep8_options)
72-
pep8_options.pop('reporter', None)
73-
for opt_n, opt_v in pep8_options.items():
74-
if isinstance(final_options.get(opt_n, None), list):
75-
final_options[opt_n] += opt_v
76-
else:
77-
final_options[opt_n] = opt_v
71+
72+
# Merge options only if the pep8 config file actually exists;
73+
# pep8 always returns a config filename, even when it doesn't exist!
74+
if os.path.isfile(pep8_options.config):
75+
pep8_options = vars(pep8_options)
76+
pep8_options.pop('reporter', None)
77+
for opt_n, opt_v in pep8_options.items():
78+
if isinstance(final_options.get(opt_n, None), list):
79+
final_options[opt_n] += opt_v
80+
else:
81+
final_options[opt_n] = opt_v
7882
except SystemExit:
7983
# Catch and ignore parser.error() when no config files are found.
8084
pass

0 commit comments

Comments
 (0)