|
1 | 1 | from ... import schema |
2 | 2 | from ...engine import default, reflection |
3 | 3 | from ...sql import compiler, expression, sqltypes, type_api |
4 | | -from typing import Any, Optional, Set, Type, Text, Pattern, Dict, TypeVar, overload, Literal |
| 4 | +from typing import Any, Optional, Set, Type, Text, Pattern, Dict, TypeVar |
5 | 5 | from datetime import timedelta |
6 | | -import uuid |
| 6 | +import sys |
7 | 7 |
|
8 | 8 | from sqlalchemy.types import INTEGER as INTEGER, BIGINT as BIGINT, SMALLINT as SMALLINT, VARCHAR as VARCHAR, \ |
9 | 9 | CHAR as CHAR, TEXT as TEXT, FLOAT as FLOAT, NUMERIC as NUMERIC, \ |
@@ -72,10 +72,15 @@ _T = TypeVar("_T") |
72 | 72 | class UUID(sqltypes.TypeEngine[_T]): |
73 | 73 | __visit_name__: str = ... |
74 | 74 | as_uuid: bool = ... |
75 | | - @overload |
76 | | - def __new__(self, as_uuid: Literal[True]) -> UUID[sqltypes.TypeEngine[uuid.UUID]]: ... |
77 | | - @overload |
78 | | - def __new__(self, as_uuid: Literal[False, None]) -> UUID[sqltypes.TypeEngine[str]]: ... |
| 75 | + if sys.version_info() >= (3,8): |
| 76 | + # Literal type is only supported since 3.8 |
| 77 | + from typing import Literal, overload |
| 78 | + import uuid |
| 79 | + @overload |
| 80 | + def __new__(self, as_uuid: Literal[True]) -> UUID[sqltypes.TypeEngine[uuid.UUID]]: ... |
| 81 | + @overload |
| 82 | + def __new__(self, as_uuid: Literal[False, None]) -> UUID[sqltypes.TypeEngine[str]]: ... |
| 83 | + |
79 | 84 | def __new__(self) -> UUID[sqltypes.TypeEngine[str]]: ... |
80 | 85 | def bind_processor(self, dialect: Any): ... |
81 | 86 | def result_processor(self, dialect: Any, coltype: Any): ... |
|
0 commit comments