Skip to content

Commit

Permalink
Provide shim for flake8 < 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Jan 30, 2018
1 parent 65e48ea commit 019039a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_abs_path(pathname):
package_dir={'': "src"},
packages=["flake8_requirements"],
install_requires=[
"flake8 > 2.0.0",
"flake8 >= 2.0.0",
"setuptools",
],
setup_requires=["pytest-runner"],
Expand Down
8 changes: 6 additions & 2 deletions src/flake8_requirements/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
from functools import wraps
from logging import getLogger

import flake8
from pkg_resources import parse_requirements

from .modules import KNOWN_3RD_PARTIES
from .modules import STDLIB_PY2
from .modules import STDLIB_PY3

# NOTE: Changing this number will alter package version as well.
__version__ = "1.1.0"
__version__ = "1.1.1"
__license__ = "MIT"

LOG = getLogger('flake8.plugin.requires')
Expand Down Expand Up @@ -262,16 +263,19 @@ def __init__(self, tree, filename, lines=None):
@classmethod
def add_options(cls, manager):
"""Register plug-in specific options."""
kw = {}
if flake8.__version__ >= '3.0.0':
kw['parse_from_config'] = True
manager.add_option(
"--known-modules",
action='store',
parse_from_config=True,
default="",
help=(
"User defined mapping between a project name and a list of"
" provided modules. For example: ``--known-modules=project:"
"[Project],extra-project:[extras,utilities]``."
),
**kw
)

@classmethod
Expand Down

0 comments on commit 019039a

Please sign in to comment.