From a81d8d51c672a47b5aaedfb88c0012123d5ed9ff Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 18 May 2022 10:54:31 +0200 Subject: [PATCH 1/3] Replace typing.re import `typing.re` has been deprecated since Python 3.8 and will be removed in Python 3.12. `Pattern` is also available in the top-level `typing` namespace. --- netmiko/snmp_autodetect.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/netmiko/snmp_autodetect.py b/netmiko/snmp_autodetect.py index e21381eca..d51d62ab1 100644 --- a/netmiko/snmp_autodetect.py +++ b/netmiko/snmp_autodetect.py @@ -20,8 +20,7 @@ Note, pysnmp is a required dependency for SNMPDetect and is intentionally not included in netmiko requirements. So installation of pysnmp might be required. """ -from typing import Optional, Dict -from typing.re import Pattern +from typing import Optional, Dict, Pattern import re try: From 8ae007db75e229d30195fa19cc52bf7f83f6803c Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 18 May 2022 16:32:51 +0200 Subject: [PATCH 2/3] Add type argument to Pattern --- netmiko/snmp_autodetect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netmiko/snmp_autodetect.py b/netmiko/snmp_autodetect.py index d51d62ab1..496e3d4ee 100644 --- a/netmiko/snmp_autodetect.py +++ b/netmiko/snmp_autodetect.py @@ -333,7 +333,7 @@ def autodetect(self) -> Optional[str]: for entry in snmp_mapper_list: for device_type, v in entry.items(): oid: str = v["oid"] # type: ignore - regex: Pattern = v["expr"] + regex: Pattern[str] = v["expr"] # Used cache data if we already queryied this OID if self._response_cache.get(oid): From 914e04894df2cf8a95dd279e26c90121e86e023f Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 18 May 2022 18:15:55 +0200 Subject: [PATCH 3/3] Add a type ignore --- netmiko/snmp_autodetect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netmiko/snmp_autodetect.py b/netmiko/snmp_autodetect.py index 496e3d4ee..f514a435c 100644 --- a/netmiko/snmp_autodetect.py +++ b/netmiko/snmp_autodetect.py @@ -333,7 +333,7 @@ def autodetect(self) -> Optional[str]: for entry in snmp_mapper_list: for device_type, v in entry.items(): oid: str = v["oid"] # type: ignore - regex: Pattern[str] = v["expr"] + regex: Pattern[str] = v["expr"] # type: ignore # Used cache data if we already queryied this OID if self._response_cache.get(oid):