From e6769b2e5683d240e68666e6e7f95afe83fd8ef3 Mon Sep 17 00:00:00 2001 From: Arkadiy Illarionov Date: Tue, 30 Apr 2024 17:07:51 +0300 Subject: [PATCH] Use typing_extensions only when needed Annotated was added in Python 3.9 Literal was added in Python 3.8 --- inflect/__init__.py | 7 ++++++- pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/inflect/__init__.py b/inflect/__init__.py index d0eded1..361f46e 100644 --- a/inflect/__init__.py +++ b/inflect/__init__.py @@ -68,6 +68,7 @@ Dict, Iterable, List, + Literal, Match, Optional, Sequence, @@ -78,7 +79,11 @@ from more_itertools import windowed_complete from typeguard import typechecked -from typing_extensions import Annotated, Literal +try: + # Python 3.9+ + from typing import Annotated +except ImportError: + from typing_extensions import Annotated class UnknownClassicalModeError(Exception): 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",