diff --git a/README.md b/README.md index d650c17..eaf8d3e 100644 --- a/README.md +++ b/README.md @@ -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`; diff --git a/pre_commit_hooks/requirements_txt_fixer.py b/pre_commit_hooks/requirements_txt_fixer.py index 623fede..ee432cb 100644 --- a/pre_commit_hooks/requirements_txt_fixer.py +++ b/pre_commit_hooks/requirements_txt_fixer.py @@ -69,10 +69,11 @@ def fix_requirements(f): else: rest = [] + # find and remove pkg-resources==0.0.0 + # which is automatically added by broken pip package under Debian for requirement in requirements: - if b'pkg-resources' in requirement.name: - if b'0.0.0' in requirement.value: - requirements.remove(requirement) + if requirement.value == b'pkg-resources==0.0.0\n': + requirements.remove(requirement) for requirement in sorted(requirements): after.extend(requirement.comments)