From 33f982b446aa1698dcc53d3cd6277f387c79b7a3 Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Mon, 30 May 2016 12:44:58 -0500 Subject: [PATCH] Rely on Python 3.4 backport of configparser Python 2.7's ConfigParser module does not allow for the behaviour we have documented for config files in Flake8 3.0. To compensate for that, we add a dependency on the configparser backport on PyPI for Python 2.7 --- docs/source/user/configuration.rst | 8 ++++++++ flake8/options/config.py | 6 +----- setup.cfg | 1 + setup.py | 2 +- tests/unit/test_config_file_finder.py | 6 +----- tox.ini | 1 + 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/source/user/configuration.rst b/docs/source/user/configuration.rst index eb9054d..6a176ec 100644 --- a/docs/source/user/configuration.rst +++ b/docs/source/user/configuration.rst @@ -155,6 +155,14 @@ This would allow us to add comments for why we're excluding items, e.g., dist max-complexity = 10 +.. note:: + + If you're using Python 2, you will notice that we download the + :mod:`configparser` backport from PyPI. That backport enables us to + support this behaviour on all supported versions of Python. + + Please do **not** open issues about this dependency. + .. note:: You can also specify ``--max-complexity`` as ``max_complexity = 10``. diff --git a/flake8/options/config.py b/flake8/options/config.py index ecc40f7..9bd7e19 100644 --- a/flake8/options/config.py +++ b/flake8/options/config.py @@ -1,13 +1,9 @@ """Config handling logic for Flake8.""" +import configparser import logging import os.path import sys -if sys.version_info < (3, 0): - import ConfigParser as configparser -else: - import configparser - LOG = logging.getLogger(__name__) __all__ = ('ConfigFileFinder', 'MergedConfigParser') diff --git a/setup.cfg b/setup.cfg index 8af25a3..831bd62 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,6 +7,7 @@ universal=1 [metadata] requires-dist = enum34; python_version<"3.4" + configparser; python_version<"3.2" [pytest] norecursedirs = .git .* *.egg* old docs dist build diff --git a/setup.py b/setup.py index c090263..8e789d0 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ if mock is None: requires = [ "pyflakes >= 0.8.1, < 1.1", "pep8 >= 1.5.7, != 1.6.0, != 1.6.1, != 1.6.2", - # "mccabe >= 0.2.1, < 0.4", + "mccabe >= 0.2.1, < 0.4", ] if sys.version_info < (3, 4): diff --git a/tests/unit/test_config_file_finder.py b/tests/unit/test_config_file_finder.py index 58009f7..8d7e920 100644 --- a/tests/unit/test_config_file_finder.py +++ b/tests/unit/test_config_file_finder.py @@ -1,9 +1,5 @@ """Tests for the ConfigFileFinder.""" -try: - import ConfigParser as configparser -except ImportError: - import configparser - +import configparser import os import sys diff --git a/tox.ini b/tox.ini index 24ef6e8..45514ea 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,7 @@ envlist = py27,py33,py34,py35,flake8 deps = mock pytest + py27: configparser commands = py.test {posargs}