Skip to content

Commit 1d6ad0d

Browse files
committed
Provide automatic removal of pkg-resources==0.0.0
Should help to deal with that pretty paintuly issue under Ubuntu/Debian family: https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1635463
1 parent 1bdd699 commit 1d6ad0d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pre_commit_hooks/requirements_txt_fixer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ def fix_requirements(f):
6969
else:
7070
rest = []
7171

72+
for requirement in requirements:
73+
if b'pkg-resources' in requirement.name:
74+
if b'0.0.0' in requirement.value:
75+
requirements.remove(requirement)
76+
7277
for requirement in sorted(requirements):
7378
after.extend(requirement.comments)
7479
after.append(requirement.value)

tests/requirements_txt_fixer_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
FAIL,
2929
b'Django\n-e git+ssh://git_url@tag#egg=ocflib\nPyMySQL\n',
3030
),
31+
(b'bar\npkg-resources==0.0.0\nfoo\n', FAIL, b'bar\nfoo\n'),
32+
(b'foo\npkg-resources==0.0.0\nbar\n', FAIL, b'bar\nfoo\n'),
3133
),
3234
)
3335
def test_integration(input_s, expected_retval, output, tmpdir):

0 commit comments

Comments
 (0)