]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
chore: add type hint for reconstructor (#12527)
authorRyu Juheon <saidbysolo@gmail.com>
Thu, 17 Apr 2025 19:48:54 +0000 (04:48 +0900)
committerGitHub <noreply@github.com>
Thu, 17 Apr 2025 19:48:54 +0000 (21:48 +0200)
* chore: add type hint for reconstructor

* chore: fix attr-defined

* chore: use defined typevar

* chore: ignore type error

lib/sqlalchemy/orm/mapper.py

index 28aa1bf32702a573da799fcc6cd596fec085fd4b..64368af7c910e805de53c4bc2b43dadfd5bcc4a5 100644 (file)
@@ -4246,7 +4246,7 @@ def _dispose_registries(registries: Set[_RegistryType], cascade: bool) -> None:
         reg._new_mappers = False
 
 
-def reconstructor(fn):
+def reconstructor(fn: _Fn) -> _Fn:
     """Decorate a method as the 'reconstructor' hook.
 
     Designates a single method as the "reconstructor", an ``__init__``-like
@@ -4272,7 +4272,7 @@ def reconstructor(fn):
         :meth:`.InstanceEvents.load`
 
     """
-    fn.__sa_reconstructor__ = True
+    fn.__sa_reconstructor__ = True  # type: ignore[attr-defined]
     return fn