Repository: asottile/setup-cfg-fmt

Issue:
normalize requirements names to be dashed-names

Discussion:

Patch:
diff --git a/setup_cfg_fmt.py b/setup_cfg_fmt.py
index be8eb0d..a2b637e 100644
--- a/setup_cfg_fmt.py
+++ b/setup_cfg_fmt.py
@@ -259,7 +259,8 @@ def _normalize_lib(lib: str) -> str:
 def _req_base(lib: str) -> str:
     basem = re.match(BASE_NAME_REGEX, lib)
     assert basem
-    return basem.group(0)
+    # pip replaces _ with - in package names
+    return basem.group(0).replace('_', '-')
 
 
 def _py_classifiers(


Test patch:
diff --git a/tests/setup_cfg_fmt_test.py b/tests/setup_cfg_fmt_test.py
index 05a7b8d..d7e7f36 100644
--- a/tests/setup_cfg_fmt_test.py
+++ b/tests/setup_cfg_fmt_test.py
@@ -72,6 +72,7 @@ def test_noop(tmpdir):
             'name = pkg\n'
             '[options]\n'
             '{} =\n'
+            '    req_req\n'
             '    req03\n'
             '    req05 <= 2,!=1\n'
             '    req06 ;python_version==2.7\n'
@@ -97,6 +98,7 @@ def test_noop(tmpdir):
             '[options]\n'
             '{} =\n'
             '    req>=2\n'
+            '    req-req\n'
             '    req01\n'
             '    req02\n'
             '    req03\n'