Skip to content

Commit

Permalink
python: utils: 'typing.Pattern' compatibility fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alesmrazek committed Oct 9, 2024
1 parent 3502fa6 commit 82323c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 1 addition & 2 deletions python/knot_resolver/datamodel/types/base_types.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
4 changes: 2 additions & 2 deletions python/knot_resolver/utils/compat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from . import asyncio
from . import asyncio, typing

__all__ = ["asyncio"]
__all__ = ["asyncio", "typing"]
8 changes: 8 additions & 0 deletions python/knot_resolver/utils/compat/typing.py
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 82323c1

Please sign in to comment.