From 7e4c4b8d5c18100b0db58f4d29fac5494fc95b52 Mon Sep 17 00:00:00 2001 From: Yurii Karabas <1998uriyyo@gmail.com> Date: Tue, 7 Feb 2023 17:43:26 -0500 Subject: Remove `typing.Self` workaround Remove ``typing.Self`` workaround, now using :pep:`673` for most methods that return ``Self``. Pull request courtesy Yurii Karabas. Fixes: #9254 Closes: #9255 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9255 Pull-request-sha: 2947df8ada79f5c3afe9c838e65993302199c2f7 Change-Id: Ic32015ad52e95a61f3913d43ea436aa9402804df --- lib/sqlalchemy/sql/ddl.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'lib/sqlalchemy/sql/ddl.py') diff --git a/lib/sqlalchemy/sql/ddl.py b/lib/sqlalchemy/sql/ddl.py index 826ff687e..75fa0ba1c 100644 --- a/lib/sqlalchemy/sql/ddl.py +++ b/lib/sqlalchemy/sql/ddl.py @@ -32,6 +32,7 @@ from .. import exc from .. import util from ..util import topological from ..util.typing import Protocol +from ..util.typing import Self if typing.TYPE_CHECKING: from .compiler import Compiled @@ -138,11 +139,6 @@ class DDLIf(typing.NamedTuple): return True -SelfExecutableDDLElement = typing.TypeVar( - "SelfExecutableDDLElement", bound="ExecutableDDLElement" -) - - class ExecutableDDLElement(roles.DDLRole, Executable, BaseDDLElement): """Base class for standalone executable DDL expression constructs. @@ -187,9 +183,7 @@ class ExecutableDDLElement(roles.DDLRole, Executable, BaseDDLElement): ) @_generative - def against( - self: SelfExecutableDDLElement, target: SchemaItem - ) -> SelfExecutableDDLElement: + def against(self, target: SchemaItem) -> Self: """Return a copy of this :class:`_schema.ExecutableDDLElement` which will include the given target. @@ -226,11 +220,11 @@ class ExecutableDDLElement(roles.DDLRole, Executable, BaseDDLElement): @_generative def execute_if( - self: SelfExecutableDDLElement, + self, dialect: Optional[str] = None, callable_: Optional[DDLIfCallable] = None, state: Optional[Any] = None, - ) -> SelfExecutableDDLElement: + ) -> Self: r"""Return a callable that will execute this :class:`_ddl.ExecutableDDLElement` conditionally within an event handler. -- cgit v1.2.1