summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/ddl.py
diff options
context:
space:
mode:
authorYurii Karabas <1998uriyyo@gmail.com>2023-02-07 17:43:26 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2023-02-08 09:23:40 -0500
commit7e4c4b8d5c18100b0db58f4d29fac5494fc95b52 (patch)
tree7f1484bcd8ea413b46063a7f7309eea82718e79c /lib/sqlalchemy/sql/ddl.py
parent33dc651030b900bad31842df927fb8454b9a75d1 (diff)
downloadsqlalchemy-7e4c4b8d5c18100b0db58f4d29fac5494fc95b52.tar.gz
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
Diffstat (limited to 'lib/sqlalchemy/sql/ddl.py')
-rw-r--r--lib/sqlalchemy/sql/ddl.py14
1 files changed, 4 insertions, 10 deletions
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.