|
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 |
| 4 | +from typing import Any, Optional, Set, Type, Text, Pattern, Dict, TypeVar, overload, Literal |
5 | 5 | from datetime import timedelta
|
| 6 | +import uuid |
6 | 7 |
|
7 | 8 | from sqlalchemy.types import INTEGER as INTEGER, BIGINT as BIGINT, SMALLINT as SMALLINT, VARCHAR as VARCHAR, \
|
8 | 9 | CHAR as CHAR, TEXT as TEXT, FLOAT as FLOAT, NUMERIC as NUMERIC, \
|
@@ -66,10 +67,16 @@ class BIT(sqltypes.TypeEngine[str]):
|
66 | 67 | def __init__(self, length: Optional[int] = ..., varying: bool = ...) -> None: ...
|
67 | 68 | PGBit = BIT
|
68 | 69 |
|
69 |
| -class UUID(sqltypes.TypeEngine[str]): |
| 70 | +_T = TypeVar("_T") |
| 71 | + |
| 72 | +class UUID(sqltypes.TypeEngine[_T]): |
70 | 73 | __visit_name__: str = ...
|
71 | 74 | as_uuid: bool = ...
|
72 |
| - def __init__(self, as_uuid: bool = ...) -> None: ... |
| 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]]: ... |
| 79 | + def __new__(self) -> UUID[sqltypes.TypeEngine[str]]: ... |
73 | 80 | def bind_processor(self, dialect: Any): ...
|
74 | 81 | def result_processor(self, dialect: Any, coltype: Any): ...
|
75 | 82 | PGUuid = UUID
|
|
0 commit comments