From 9e28aaf2752dc22adaacbd8f65fb8669d3da456a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Socho=C5=84?= Date: Mon, 26 Mar 2018 00:02:23 +0200 Subject: [PATCH] Simplify check, extend README --- README.md | 2 +- pre_commit_hooks/requirements_txt_fixer.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) 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)