Repository: pre-commit/pre-commit-hooks

Issue:
requirements-txt-fixer doesn't handle new pkg_resources==0.0.0
Perhaps something changed on PyPI but instead of Ubuntu 20.04 generating `pkg-resources==0.0.0` it now generates `npkg_resources==0.0.0` which should also be ignored.

Discussion:
ericfrederich: I'd appreciate this merge.  I'm not sure if something changed on PyPI or Debian or Ubuntu, but now on my Ubuntu machine I'm getting `pkg_resources` with an underscore instead of `pkg-resources` like I used to get.
asottile: can't merge without a test demonstrating the new behaviour

Patch:
diff --git a/pre_commit_hooks/requirements_txt_fixer.py b/pre_commit_hooks/requirements_txt_fixer.py
index 261acc9..07b57e1 100644
--- a/pre_commit_hooks/requirements_txt_fixer.py
+++ b/pre_commit_hooks/requirements_txt_fixer.py
@@ -115,7 +115,10 @@ def fix_requirements(f: IO[bytes]) -> int:
     # 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'
+        if req.value not in [
+            b'pkg-resources==0.0.0\n',
+            b'pkg_resources==0.0.0\n',
+        ]
     ]
 
     # sort the requirements and remove duplicates


Test patch:
diff --git a/tests/requirements_txt_fixer_test.py b/tests/requirements_txt_fixer_test.py
index c400be1..c0d2c65 100644
--- a/tests/requirements_txt_fixer_test.py
+++ b/tests/requirements_txt_fixer_test.py
@@ -82,6 +82,8 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement
         ),
         (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'),
+        (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'),
         (
             b'git+ssh://git_url@tag#egg=ocflib\nDjango\nijk\n',
             FAIL,