mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-04 11:16:53 +00:00
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:
commit
20baf1a22a
3 changed files with 10 additions and 1 deletions
|
|
@ -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`;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue