Skip to content

Commit 2490d7c

Browse files
author
Paul Duncan
committed
Import of Annotated and Literal from typing_extensions according to Python version
1 parent 60a4670 commit 2490d7c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

predicthq/endpoints/v1/beam/schemas.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
from datetime import datetime
33
from predicthq.endpoints.schemas import ArgKwargResultSet
44
from typing import Optional, List
5-
from typing import Annotated, Literal
65

7-
# Check if we're running on Python < 3.11
86
# Python < 3.11 does not have StrEnum in the enum module
97
import sys
108
if sys.version_info < (3, 11):
@@ -15,6 +13,18 @@ class StrEnum(str, enum.Enum):
1513
else:
1614
from enum import StrEnum
1715

16+
# Python < 3.9 does not have Annotated in the enum module
17+
if sys.version_info < (3, 9):
18+
from typing_extensions import Annotated
19+
else:
20+
from typing import Annotated, Literal
21+
22+
# Python < 3.8 does not have Literal in the enum module
23+
if sys.version_info < (3, 8):
24+
from typing_extensions import Literal
25+
else:
26+
from typing import Literal
27+
1828

1929
class BeamPaginationResultSet(ArgKwargResultSet):
2030
def has_next(self):

0 commit comments

Comments
 (0)