from typing import Any
from typing import Awaitable
from typing import Callable
+from typing import cast
from typing import Dict
from typing import Generic
from typing import Iterable
"""
+ # result_obj = self.sync_session.get(entity, ident)
+
result_obj = await greenlet_spawn(
- self.sync_session.get,
+ cast("Callable[..., _O]", self.sync_session.get),
entity,
ident,
options=options,
_T_co = TypeVar("_T_co", bound=Any, covariant=True)
-# I would have preferred this were bound=object however it seems
-# to not travel in all situations when defined in that way.
-_O = TypeVar("_O", bound=Any)
+_O = TypeVar("_O", bound=object)
"""The 'ORM mapped object' type.
"""
-_OO = TypeVar("_OO", bound=object)
-"""The 'ORM mapped object, that's definitely object' type.
-
-"""
-
if TYPE_CHECKING:
_RegistryType = _registry_type
"""
def decorate(cls: Type[_O]) -> Type[_O]:
- cls._sa_apply_dc_transforms = {
- "init": init,
- "repr": repr,
- "eq": eq,
- "order": order,
- "unsafe_hash": unsafe_hash,
- "match_args": match_args,
- "kw_only": kw_only,
- "dataclass_callable": dataclass_callable,
- }
+ setattr(
+ cls,
+ "_sa_apply_dc_transforms",
+ {
+ "init": init,
+ "repr": repr,
+ "eq": eq,
+ "order": order,
+ "unsafe_hash": unsafe_hash,
+ "match_args": match_args,
+ "kw_only": kw_only,
+ "dataclass_callable": dataclass_callable,
+ },
+ )
_as_declarative(self, cls, cls.__dict__)
return cls
return self._pending_mutations[key]
def __getstate__(self) -> Dict[str, Any]:
- state_dict = {
+ state_dict: Dict[str, Any] = {
"instance": self.obj(),
"class_": self.class_,
"committed_state": self.committed_state,
_weak_entity: weakref.ref[AliasedClass[_O]]
"""the AliasedClass that refers to this AliasedInsp"""
- _target: Union[_O, AliasedClass[_O]]
+ _target: Union[Type[_O], AliasedClass[_O]]
"""the thing referred towards by the AliasedClass/AliasedInsp.
In the vast majority of cases, this is the mapped class. However