From 752e5c8b15c9cbc1af32a9c0d00d78fdfd429fc6 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 11 Jan 2023 14:53:21 +0100 Subject: [PATCH 1/2] SQLAlchemy: Annotate text() --- stubs/SQLAlchemy/sqlalchemy/sql/elements.pyi | 3 ++- stubs/SQLAlchemy/sqlalchemy/sql/expression.pyi | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/stubs/SQLAlchemy/sqlalchemy/sql/elements.pyi b/stubs/SQLAlchemy/sqlalchemy/sql/elements.pyi index 367827958ed8..a702c383cc39 100644 --- a/stubs/SQLAlchemy/sqlalchemy/sql/elements.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/sql/elements.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from typing import Any, Generic, TypeVar from typing_extensions import Literal @@ -136,7 +137,7 @@ class TextClause( def __and__(self, other): ... key: Any text: Any - def __init__(self, text, bind: Any | None = ...): ... + def __init__(self, text: str, bind: Incomplete | None = None) -> None: ... def bindparams(self, *binds, **names_to_values) -> None: ... def columns(self, *cols, **types): ... @property diff --git a/stubs/SQLAlchemy/sqlalchemy/sql/expression.pyi b/stubs/SQLAlchemy/sqlalchemy/sql/expression.pyi index 8364b0e69197..44ca4b6ed9df 100644 --- a/stubs/SQLAlchemy/sqlalchemy/sql/expression.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/sql/expression.pyi @@ -163,7 +163,9 @@ lateral: Incomplete or_: Incomplete bindparam: Incomplete select: Incomplete -text: Incomplete + +def text(text: str, bind: Incomplete | None = None) -> TextClause: ... + table: Incomplete column: Incomplete over: Incomplete From 718b625ec964eabafcb63739191cd7fa29d843d4 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 11 Jan 2023 15:15:25 +0100 Subject: [PATCH 2/2] Fix return type of TextClause.bindparams() --- stubs/SQLAlchemy/sqlalchemy/sql/elements.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/SQLAlchemy/sqlalchemy/sql/elements.pyi b/stubs/SQLAlchemy/sqlalchemy/sql/elements.pyi index a702c383cc39..89463124bf73 100644 --- a/stubs/SQLAlchemy/sqlalchemy/sql/elements.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/sql/elements.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, Self from typing import Any, Generic, TypeVar from typing_extensions import Literal @@ -138,7 +138,7 @@ class TextClause( key: Any text: Any def __init__(self, text: str, bind: Incomplete | None = None) -> None: ... - def bindparams(self, *binds, **names_to_values) -> None: ... + def bindparams(self: Self, *binds, **names_to_values) -> Self: ... def columns(self, *cols, **types): ... @property def type(self): ...