summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lee <IanLee1521@gmail.com>2016-11-03 16:47:00 -0700
committerGitHub <noreply@github.com>2016-11-03 16:47:00 -0700
commitee9c279bcdb50d306ad899fc32cc546f2603c455 (patch)
tree41d26775b5fec2597e2e93b6072f3d29ef2b5c01
parent5c4ca67b970258cd4c5ab0e36967b81255911fdb (diff)
parent2cc7a8abce1f5442dc0d23da546752dcb611bc23 (diff)
downloadpep8-ee9c279bcdb50d306ad899fc32cc546f2603c455.tar.gz
Merge pull request #591 from daspecster/support-pep8-pycodestyle-config
Check for both [pep8] and [pycodestyle] config sections.
-rwxr-xr-xpycodestyle.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/pycodestyle.py b/pycodestyle.py
index a14369e..64a57ec 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -55,6 +55,7 @@ import re
import sys
import time
import tokenize
+import warnings
from fnmatch import fnmatch
from optparse import OptionParser
@@ -2144,8 +2145,14 @@ def read_config(options, args, arglist, parser):
print('cli configuration: %s' % cli_conf)
config.read(cli_conf)
- pep8_section = parser.prog
- if config.has_section(pep8_section):
+ pycodestyle_section = None
+ if config.has_section(parser.prog):
+ pycodestyle_section = parser.prog
+ elif config.has_section('pep8'):
+ pycodestyle_section = 'pep8' # Deprecated
+ warnings.warn('[pep8] section is deprecated. Use [pycodestyle].')
+
+ if pycodestyle_section:
option_list = dict([(o.dest, o.type or o.action)
for o in parser.option_list])
@@ -2153,20 +2160,21 @@ def read_config(options, args, arglist, parser):
(new_options, __) = parser.parse_args([])
# Second, parse the configuration
- for opt in config.options(pep8_section):
+ for opt in config.options(pycodestyle_section):
if opt.replace('_', '-') not in parser.config_options:
print(" unknown option '%s' ignored" % opt)
continue
if options.verbose > 1:
- print(" %s = %s" % (opt, config.get(pep8_section, opt)))
+ print(" %s = %s" % (opt,
+ config.get(pycodestyle_section, opt)))
normalized_opt = opt.replace('-', '_')
opt_type = option_list[normalized_opt]
if opt_type in ('int', 'count'):
- value = config.getint(pep8_section, opt)
+ value = config.getint(pycodestyle_section, opt)
elif opt_type in ('store_true', 'store_false'):
- value = config.getboolean(pep8_section, opt)
+ value = config.getboolean(pycodestyle_section, opt)
else:
- value = config.get(pep8_section, opt)
+ value = config.get(pycodestyle_section, opt)
if normalized_opt == 'exclude':
value = normalize_paths(value, local_dir)
setattr(new_options, normalized_opt, value)