Repository: netromdk/vermin

Issue:
False positive when using backported zoneinfo
**Describe the bug**

I'm trying to use `vermin` on a project that uses `zoneinfo`. The project is properly set up to install the backport on Python < 3.9.

However, vermin reports this as a violation, and won't take `--backport zoneinfo`.

**To Reproduce**

```sh
git clone https://github.com/WhyNotHugo/django-afip.git
cd django-afip
vermin --no-tips --target=3.7 --violations .
vermin --no-tips --target=3.7 --violations --backport zoneinfo .
```

**Expected behavior**

The latter should work.

**Environment (please complete the following information):**

```con
> vermin --version
1.5.1
 
> git --version   
git version 2.40.1
````

**Additional context**

-


Discussion:

Patch:
diff --git a/vermin/backports.py b/vermin/backports.py
index f10c6f8..2d32b07 100644
--- a/vermin/backports.py
+++ b/vermin/backports.py
@@ -27,6 +27,8 @@ BACKPORTS = (
   ("typing_extensions==4.0", ["https://pypi.org/project/typing-extensions/4.0.0/"], (None, (3, 6))),
   ("typing_extensions==4.3", ["https://pypi.org/project/typing-extensions/4.3.0/"], (None, (3, 7))),
   ("typing_extensions", ["https://pypi.org/project/typing-extensions/4.3.0/"], (None, (3, 7))),
+
+  ("zoneinfo", ["https://pypi.org/project/backports.zoneinfo/"], (None, (3, 6))),
 )
 
 class Backports:
diff --git a/vermin/rules.py b/vermin/rules.py
index f80f006..0d76ee5 100644
--- a/vermin/rules.py
+++ b/vermin/rules.py
@@ -192,7 +192,7 @@ def MOD_REQS(config):
     "xmlrpclib": ((2, 2), None),
     "zipapp": (None, (3, 5)),
     "zipimport": ((2, 3), (3, 0)),
-    "zoneinfo": (None, (3, 9)),
+    "zoneinfo": bpv("zoneinfo", (None, (3, 9)), config),
    }
 
 # Module member requirements: member -> (module, requirements)


Test patch:
diff --git a/tests/backports.py b/tests/backports.py
index c8061e1..e09c89a 100644
--- a/tests/backports.py
+++ b/tests/backports.py
@@ -20,6 +20,7 @@ class VerminBackportsTests(VerminTest):
       "typing_extensions==4.0",
       "typing_extensions==4.3",
       "typing_extensions",
+      "zoneinfo",
     ), Backports.modules())
 
   def test_is_backport(self):
@@ -41,7 +42,8 @@ class VerminBackportsTests(VerminTest):
    typing                 - https://pypi.org/project/typing/ (2.7, 3.2)
    typing_extensions==4.0 - https://pypi.org/project/typing-extensions/4.0.0/ (!2, 3.6)
    typing_extensions==4.3 - https://pypi.org/project/typing-extensions/4.3.0/ (!2, 3.7)
-   typing_extensions      - https://pypi.org/project/typing-extensions/4.3.0/ (!2, 3.7)""",
+   typing_extensions      - https://pypi.org/project/typing-extensions/4.3.0/ (!2, 3.7)
+   zoneinfo               - https://pypi.org/project/backports.zoneinfo/ (!2, 3.6)""",
                      Backports.str(3))
 
   def test_version_filter(self):
@@ -66,6 +68,7 @@ class VerminBackportsTests(VerminTest):
       "statistics",
       "typing",
       "typing_extensions",
+      "zoneinfo",
     ], Backports.unversioned_filter(Backports.modules()))
 
   def test_expand_versions(self):