Skip to content

Commit c8c637a

Browse files
committed
Fix --skip-incompatible flag
Why it is a bug --------------- The flag also made the the code skip all other extra requirements. This was due to a wrongfully added `else` clause, which should not be there: because of it, the code that added requirements was triggered only `if not options.skip_incompatible`, which is obviously wrong. Why this patch fixes it ----------------------- This patch makes the `explicit.add` code run even when the `--skip-incompatible` flag is present. With this patch, both of the branches that ignored the requirements still work: the `options.ignore_reqs` still uses continue to bail on a requirement, so does `options.skip_incompatible`.
1 parent 48b4584 commit c8c637a

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Release History
33
---------------
44

5+
2.3.1
6+
7+
- Fixed `--skip-incompatible` skipping other requirements too.
8+
59
2.3.0
610

711
- Support pip >= 21.2.1

pip_check_reqs/__init__.py

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

pip_check_reqs/common.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,8 @@ def find_required_modules(options, requirements_filename: str):
152152
'marker): %s', requirement_string)
153153
continue
154154

155-
else:
156-
log.debug('found requirement: %s', requirement_name)
157-
explicit.add(canonicalize_name(requirement_name))
155+
log.debug('found requirement: %s', requirement_name)
156+
explicit.add(canonicalize_name(requirement_name))
158157

159158
return explicit
160159

tests/test_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def ignore_reqs(self, modname):
195195
options=options(),
196196
requirements_filename=str(fake_requirements_file),
197197
)
198-
assert not reqs
198+
assert reqs == {'ham', 'eggs'}
199199

200200

201201
def test_find_imported_modules_sets_encoding_to_utf8_when_reading(tmp_path):

0 commit comments

Comments
 (0)