]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
python: utils: 'typing.Pattern' compatibility fix docs-develop-ci-m-6n00ea/deployments/5302
authorAleš Mrázek <ales.mrazek@nic.cz>
Tue, 8 Oct 2024 20:33:10 +0000 (22:33 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Wed, 9 Oct 2024 07:05:24 +0000 (09:05 +0200)
python/knot_resolver/datamodel/types/base_types.py
python/knot_resolver/utils/compat/__init__.py
python/knot_resolver/utils/compat/typing.py [new file with mode: 0644]

index 038511482d6459fb73dde0435275249735932993..90210b5a0d29efecd9ff69a079d333a1de5ac011 100644 (file)
@@ -1,8 +1,7 @@
 import re
 from typing import Any, Dict, Type
 
-from typing_extensions import Pattern
-
+from knot_resolver.utils.compat.typing import Pattern
 from knot_resolver.utils.modeling import BaseValueType
 
 
index 53993f6cedc914e11f79246e858328af52e74ea9..52ffaa9cb3d9168c19d750d50330ab7e71a421dc 100644 (file)
@@ -1,3 +1,3 @@
-from . import asyncio
+from . import asyncio, typing
 
-__all__ = ["asyncio"]
+__all__ = ["asyncio", "typing"]
diff --git a/python/knot_resolver/utils/compat/typing.py b/python/knot_resolver/utils/compat/typing.py
new file mode 100644 (file)
index 0000000..15654d3
--- /dev/null
@@ -0,0 +1,8 @@
+# The 'typing.Pattern' is deprecated since python 3.8 and is removed in version 3.12.
+# https://docs.python.org/3.9/library/typing.html#typing.Pattern
+try:
+    from typing import Pattern
+except ImportError:
+    from re import Pattern
+
+__all__ = ["Pattern"]