From cd608f40ab6b24ca9032b5d183bcc4345a0a693d Mon Sep 17 00:00:00 2001 From: Keigo Kawamura Date: Thu, 15 Oct 2020 13:56:36 +0900 Subject: [PATCH 1/2] Update external/mypy to 0.790 --- external/mypy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mypy b/external/mypy index d9dea5f..69a055a 160000 --- a/external/mypy +++ b/external/mypy @@ -1 +1 @@ -Subproject commit d9dea5f3ad30bb449e4167b3e8476684ded0482e +Subproject commit 69a055a7632e2444fcb2bfb022d04f4546358d50 From 8db9cac1810e6442098a5704b6488cd4be5c9470 Mon Sep 17 00:00:00 2001 From: Thijs Damsma Date: Mon, 9 Nov 2020 21:25:36 +0100 Subject: [PATCH 2/2] Support UUID=True --- sqlalchemy-stubs/dialects/postgresql/base.pyi | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/sqlalchemy-stubs/dialects/postgresql/base.pyi b/sqlalchemy-stubs/dialects/postgresql/base.pyi index d910e5c..7858208 100644 --- a/sqlalchemy-stubs/dialects/postgresql/base.pyi +++ b/sqlalchemy-stubs/dialects/postgresql/base.pyi @@ -1,13 +1,20 @@ 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 +from typing import Any, Optional, Set, Type, Text, Pattern, Dict, TypeVar, overload 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, \ DATE as DATE, BOOLEAN as BOOLEAN, REAL as REAL +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + AUTOCOMMIT_REGEXP: Pattern[Text] RESERVED_WORDS: Set[str] @@ -66,10 +73,17 @@ class BIT(sqltypes.TypeEngine[str]): def __init__(self, length: Optional[int] = ..., varying: bool = ...) -> None: ... PGBit = BIT -class UUID(sqltypes.TypeEngine[str]): +_T = TypeVar("_T") + +class UUID(sqltypes.TypeEngine[_T]): __visit_name__: str = ... as_uuid: bool = ... - def __init__(self, as_uuid: bool = ...) -> None: ... + @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]]: ... + @overload + def __new__(self) -> UUID[sqltypes.TypeEngine[str]]: ... def bind_processor(self, dialect: Any): ... def result_processor(self, dialect: Any, coltype: Any): ... PGUuid = UUID