Skip to content

Remove obsolete code paths (working subset) #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions pip_check_reqs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@

from . import __version__

# Between different versions of pip the location of PipSession has changed.
try:
from pip._internal.network.session import PipSession
except ImportError: # pragma: no cover
from pip._internal.download import PipSession
from pip._internal.network.session import PipSession
from pip._internal.req.constructors import install_req_from_line
from pip._internal.req.req_file import parse_requirements


Expand Down Expand Up @@ -137,16 +134,9 @@ def find_required_modules(options, requirements_filename: str):
explicit = set()
for requirement in parse_requirements(requirements_filename,
session=PipSession()):
try:
requirement_name = requirement.name
# The type of "requirement" changed between pip versions.
# We exclude the "except" from coverage so that on any pip version we
# can report 100% coverage.
except AttributeError: # pragma: no cover
from pip._internal.req.constructors import install_req_from_line
requirement_name = install_req_from_line(
requirement.requirement,
).name
requirement_name = install_req_from_line(
requirement.requirement,
).name

if options.ignore_reqs(requirement):
log.debug('ignoring requirement: %s', requirement_name)
Expand Down Expand Up @@ -193,13 +183,10 @@ def ignorer(ignore_cfg):
def f(candidate, ignore_cfg=ignore_cfg):
for ignore in ignore_cfg:
try:
from pip._internal.req.constructors import (
install_req_from_line,
)
candidate_path = install_req_from_line( # pragma: no cover
candidate_path = install_req_from_line(
candidate.requirement,
).name
except (ImportError, AttributeError):
except AttributeError:
try:
candidate_path = candidate.name
except AttributeError:
Expand Down
20 changes: 5 additions & 15 deletions pip_check_reqs/find_missing_reqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@

from packaging.utils import canonicalize_name
from pip._internal.commands.show import search_packages_info
# Between different versions of pip the location of PipSession has changed.
try:
from pip._internal.network.session import PipSession
except ImportError: # pragma: no cover
from pip._internal.download import PipSession
from pip._internal.network.session import PipSession
from pip._internal.req.constructors import install_req_from_line
from pip._internal.req.req_file import parse_requirements

from pip_check_reqs import common
Expand Down Expand Up @@ -89,16 +86,9 @@ def find_missing_reqs(options, requirements_filename):
requirements_filename,
session=PipSession(),
):
try:
requirement_name = requirement.name
# The type of "requirement" changed between pip versions.
# We exclude the "except" from coverage so that on any pip version we
# can report 100% coverage.
except AttributeError: # pragma: no cover
from pip._internal.req.constructors import install_req_from_line
requirement_name = install_req_from_line(
requirement.requirement,
).name
requirement_name = install_req_from_line(
requirement.requirement,
).name

log.debug('found requirement: %s', requirement_name)
explicit.add(canonicalize_name(requirement_name))
Expand Down