Merge pull request #275 from nvtkaszpir/feature/fix-broken-pkg-resources

Provide automatic removal of pkg-resources==0.0.0
This commit is contained in:
Anthony Sottile 2018-03-25 15:46:53 -07:00 committed by GitHub
commit 20baf1a22a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View file

@ -90,7 +90,7 @@ Add this to your `.pre-commit-config.yaml`
- `--indent ...` - Control the indentation (either a number for a number of spaces or a string of whitespace). Defaults to 4 spaces.
- `--no-sort-keys` - when autofixing, retain the original key ordering (instead of sorting the keys)
- `--top-keys comma,separated,keys` - Keys to keep at the top of mappings.
- `requirements-txt-fixer` - Sorts entries in requirements.txt
- `requirements-txt-fixer` - Sorts entries in requirements.txt and removes incorrect entry for `pkg-resources==0.0.0`
- `sort-simple-yaml` - Sorts simple YAML files which consist only of top-level keys, preserving comments and blocks.
- `trailing-whitespace` - Trims trailing whitespace.
- Markdown linebreak trailing spaces preserved for `.md` and`.markdown`;

View file

@ -69,6 +69,13 @@ def fix_requirements(f):
else:
rest = []
# find and remove pkg-resources==0.0.0
# which is automatically added by broken pip package under Debian
requirements = [
req for req in requirements
if req.value != b'pkg-resources==0.0.0\n'
]
for requirement in sorted(requirements):
after.extend(requirement.comments)
after.append(requirement.value)

View file

@ -28,6 +28,8 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement
FAIL,
b'Django\n-e git+ssh://git_url@tag#egg=ocflib\nPyMySQL\n',
),
(b'bar\npkg-resources==0.0.0\nfoo\n', FAIL, b'bar\nfoo\n'),
(b'foo\npkg-resources==0.0.0\nbar\n', FAIL, b'bar\nfoo\n'),
),
)
def test_integration(input_s, expected_retval, output, tmpdir):