Skip to content

Fix SSH requirements crash #61

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
Release History
---------------

2.2.2

- Fix crash on requirements of the "git+ssh://..." format.

2.2.1

- Python source is now always read using utf-8, even if default encoding for
reading files is set otherwise.

Expand Down
2 changes: 1 addition & 1 deletion pip_check_reqs/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.2.1'
__version__ = '2.2.2'
7 changes: 7 additions & 0 deletions pip_check_reqs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from packaging.utils import canonicalize_name
from packaging.markers import Marker

# Between different versions of pip the location of PipSession has changed.
try:
from pip._internal.network.session import PipSession
Expand Down Expand Up @@ -141,6 +142,12 @@ def find_required_modules(options, requirements_filename: str):
requirement.requirement,
).name

if requirement_name is None:
# This happens when the requirement parsing fails, for e.g. a
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this only happen in this circumstance?

# requirement in the format of
# git+ssh://[email protected]/...
continue

if options.ignore_reqs(requirement):
log.debug('ignoring requirement: %s', requirement_name)
continue
Expand Down
4 changes: 3 additions & 1 deletion tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ class options:
options.ignore_reqs = common.ignorer(ignore_cfg=['barfoo'])

fake_requirements_file = tmp_path / 'requirements.txt'
fake_requirements_file.write_text('foobar==1\nbarfoo==2')
fake_requirements_file.write_text('foobar==1\nbarfoo==2\n'
'git+ssh://[email protected]/'
'r1chardj0n3s/pip-check-reqs.git@master')

reqs = common.find_required_modules(
options=options,
Expand Down