Skip to content

Commit

Permalink
only apply Literal type checking for 3.8 and higher
Browse files Browse the repository at this point in the history
  • Loading branch information
tdamsma committed Nov 10, 2020
1 parent 3f1efab commit 9b500d9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions sqlalchemy-stubs/dialects/postgresql/base.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from ... import schema
from ...engine import default, reflection
from ...sql import compiler, expression, sqltypes, type_api
from typing import Any, Optional, Set, Type, Text, Pattern, Dict, TypeVar, overload, Literal
from typing import Any, Optional, Set, Type, Text, Pattern, Dict, TypeVar
from datetime import timedelta
import uuid
import sys

from sqlalchemy.types import INTEGER as INTEGER, BIGINT as BIGINT, SMALLINT as SMALLINT, VARCHAR as VARCHAR, \
CHAR as CHAR, TEXT as TEXT, FLOAT as FLOAT, NUMERIC as NUMERIC, \
Expand Down Expand Up @@ -72,10 +72,15 @@ _T = TypeVar("_T")
class UUID(sqltypes.TypeEngine[_T]):
__visit_name__: str = ...
as_uuid: bool = ...
@overload
def __new__(self, as_uuid: Literal[True]) -> UUID[sqltypes.TypeEngine[uuid.UUID]]: ...
@overload
def __new__(self, as_uuid: Literal[False, None]) -> UUID[sqltypes.TypeEngine[str]]: ...
if sys.version_info() >= (3,8):
# Literal type is only supported since 3.8
from typing import Literal, overload
import uuid
@overload
def __new__(self, as_uuid: Literal[True]) -> UUID[sqltypes.TypeEngine[uuid.UUID]]: ...
@overload
def __new__(self, as_uuid: Literal[False, None]) -> UUID[sqltypes.TypeEngine[str]]: ...

def __new__(self) -> UUID[sqltypes.TypeEngine[str]]: ...
def bind_processor(self, dialect: Any): ...
def result_processor(self, dialect: Any, coltype: Any): ...
Expand Down

0 comments on commit 9b500d9

Please sign in to comment.