diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2013-03-24 16:10:55 +0100 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2013-03-24 16:10:55 +0100 |
commit | b2a2d9e687ecd24af3275f53435dc13a9e7157ad (patch) | |
tree | bec4d89d25f07865014b7645298d8857fe4fb4d2 | |
parent | f44612e508e1433c40e7f394d171451587425426 (diff) | |
download | pep8-b2a2d9e687ecd24af3275f53435dc13a9e7157ad.tar.gz |
Read configuration from both tox.ini and setup.cfg; issue #182
-rw-r--r-- | CHANGES.txt | 4 | ||||
-rw-r--r-- | docs/intro.rst | 6 | ||||
-rwxr-xr-x | pep8.py | 18 |
3 files changed, 13 insertions, 15 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 4298702..774ace0 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,10 @@ Changelog * Honor ``# noqa`` for errors E711 and E712. (Issue #180) +* When both a ``tox.ini`` and a ``setup.cfg`` are present in the project + directory, merge their contents. The ``tox.ini`` file takes + precedence (same as before). (Issue #182) + 1.4.5 (2013-03-06) ------------------ diff --git a/docs/intro.rst b/docs/intro.rst index c22df98..d73a3c8 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -163,9 +163,9 @@ Example:: ignore = E226,E302,E41 max-line-length = 160 -At the project level, a ``.pep8`` file, a ``tox.ini`` file or a ``setup.cfg`` -file is read if present. Only the first file is considered. If this file -does not have a ``[pep8]`` section, no project specific configuration is +At the project level, a ``tox.ini`` file or a ``setup.cfg`` file is read if +present (``.pep8`` file is also supported, but it is deprecated). If none of +these files have a ``[pep8]`` section, no project specific configuration is loaded. If the ``ignore`` option is not in the configuration and not in the arguments, @@ -69,7 +69,7 @@ if sys.platform == 'win32': else: DEFAULT_CONFIG = os.path.join(os.getenv('XDG_CONFIG_HOME') or os.path.expanduser('~/.config'), 'pep8') -PROJECT_CONFIG = ('.pep8', 'tox.ini', 'setup.cfg') +PROJECT_CONFIG = ('setup.cfg', 'tox.ini', '.pep8') TESTSUITE_PATH = os.path.join(os.path.dirname(__file__), 'testsuite') MAX_LINE_LENGTH = 79 REPORT_FORMAT = { @@ -1742,17 +1742,11 @@ def read_config(options, args, arglist, parser): parent = tail = args and os.path.abspath(os.path.commonprefix(args)) while tail: - for name in PROJECT_CONFIG: - local_conf = os.path.join(parent, name) - if os.path.isfile(local_conf): - break - else: - parent, tail = os.path.split(parent) - continue - if options.verbose: - print('local configuration: %s' % local_conf) - config.read(local_conf) - break + if config.read([os.path.join(parent, fn) for fn in PROJECT_CONFIG]): + if options.verbose: + print('local configuration: in %s' % parent) + break + parent, tail = os.path.split(parent) pep8_section = parser.prog if config.has_section(pep8_section): |