Skip to content

Commit 574389e

Browse files
committed
Fix SSH requirement crash
1 parent d17aa5e commit 574389e

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
Release History
33
---------------
44

5+
2.2.2
6+
7+
- Fix crash on requirements of the "git+ssh://..." format.
8+
59
2.2.1
10+
611
- Python source is now always read using utf-8, even if default encoding for
712
reading files is set otherwise.
813

pip_check_reqs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.2.1'
1+
__version__ = '2.2.2'

pip_check_reqs/common.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from packaging.utils import canonicalize_name
99
from packaging.markers import Marker
10+
1011
# Between different versions of pip the location of PipSession has changed.
1112
try:
1213
from pip._internal.network.session import PipSession
@@ -141,6 +142,12 @@ def find_required_modules(options, requirements_filename: str):
141142
requirement.requirement,
142143
).name
143144

145+
if requirement_name is None:
146+
# This happens when the requirement parsing fails, for e.g. a
147+
# requirement in the format of
148+
# git+ssh://[email protected]/...
149+
continue
150+
144151
if options.ignore_reqs(requirement):
145152
log.debug('ignoring requirement: %s', requirement_name)
146153
continue

tests/test_common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ class options:
170170
options.ignore_reqs = common.ignorer(ignore_cfg=['barfoo'])
171171

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

175177
reqs = common.find_required_modules(
176178
options=options,

0 commit comments

Comments
 (0)