Skip to content

Commit

Permalink
Drop support for unmaintained python2
Browse files Browse the repository at this point in the history
Closes #71
  • Loading branch information
arkq committed May 15, 2023
1 parent bac0b04 commit 8d58340
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 363 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bdist_wheel]
universal = 1
python-tag = py3

[doc8]
max-line-length = 99
Expand Down
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import with_statement

import re
from os import path

Expand Down Expand Up @@ -27,7 +25,7 @@ def get_abs_path(pathname):
package_dir={'': "src"},
packages=["flake8_requirements"],
install_requires=[
"flake8 >= 2.0.0",
"flake8 >= 4.0.0",
"setuptools >= 10.0.0",
"tomli>=1.2.1; python_version < '3.11'",
],
Expand All @@ -43,8 +41,8 @@ def get_abs_path(pathname):
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only"
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Quality Assurance",
],
Expand Down
30 changes: 11 additions & 19 deletions src/flake8_requirements/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from functools import wraps
from logging import getLogger

import flake8
from pkg_resources import parse_requirements
from pkg_resources import yield_lines

Expand All @@ -18,11 +17,10 @@
import tomli as tomllib

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.7.8"
__version__ = "2.0.0"
__license__ = "MIT"

LOG = getLogger('flake8.plugin.requirements')
Expand All @@ -33,10 +31,7 @@
}

STDLIB = set()
if sys.version_info[0] == 2:
STDLIB.update(STDLIB_PY2)
if sys.version_info[0] == 3:
STDLIB.update(STDLIB_PY3)
STDLIB.update(STDLIB_PY3)


def memoize(f):
Expand Down Expand Up @@ -334,48 +329,45 @@ 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',
default="",
parse_from_config=True,
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)
))
manager.add_option(
"--requirements-file",
action='store',
parse_from_config=True,
help=(
"Specify the name (location) of the requirements text file. "
"Unless an absolute path is given, the file will be searched "
"relative to the project's root directory. If this option is "
"given, requirements from setup.py, setup.cfg or "
"pyproject.toml will not be taken into account."
),
**kw)
))
manager.add_option(
"--requirements-max-depth",
type=int if flake8.__version__ >= '3.8.0' else 'int',
type=int,
default=1,
parse_from_config=True,
help=(
"Max depth to resolve recursive requirements. Defaults to 1 "
"(one level of recursion allowed)."
),
**kw)
))
manager.add_option(
"--scan-host-site-packages",
action='store_true',
parse_from_config=True,
help=(
"Scan host's site-packages directory for 3rd party projects, "
"which provide more than one module or the name of the module"
" is different than the project name itself."
),
**kw)
))

@classmethod
def parse_options(cls, options):
Expand Down
Loading

0 comments on commit 8d58340

Please sign in to comment.