diff --git a/inflect/__init__.py b/inflect/__init__.py index d0eded1..3eec27f 100644 --- a/inflect/__init__.py +++ b/inflect/__init__.py @@ -68,6 +68,7 @@ Dict, Iterable, List, + Literal, Match, Optional, Sequence, @@ -78,7 +79,8 @@ from more_itertools import windowed_complete from typeguard import typechecked -from typing_extensions import Annotated, Literal + +from .compat.py38 import Annotated class UnknownClassicalModeError(Exception): diff --git a/inflect/compat/__init__.py b/inflect/compat/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/inflect/compat/py38.py b/inflect/compat/py38.py new file mode 100644 index 0000000..a2d01bd --- /dev/null +++ b/inflect/compat/py38.py @@ -0,0 +1,7 @@ +import sys + + +if sys.version_info > (3, 9): + from typing import Annotated +else: # pragma: no cover + from typing_extensions import Annotated # noqa: F401 diff --git a/newsfragments/211.feature.rst b/newsfragments/211.feature.rst new file mode 100644 index 0000000..3971e55 --- /dev/null +++ b/newsfragments/211.feature.rst @@ -0,0 +1 @@ +Restricted typing_extensions to Python 3.8. \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 1cb9e5e..cb5a0a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ requires-python = ">=3.8" dependencies = [ "more_itertools", "typeguard >= 4.0.1", - "typing_extensions", + "typing_extensions ; python_version<'3.9'", ] keywords = [ "plural",