diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-04-07 12:37:23 -0400 |
---|---|---|
committer | mike bayer <mike_mp@zzzcomputing.com> | 2022-04-12 02:09:50 +0000 |
commit | aa9cd878e8249a4a758c7f968e929e92fede42a5 (patch) | |
tree | 1be1c9dc24dd247a150be55d65bfc56ebaf111bc /lib/sqlalchemy/ext/asyncio/scoping.py | |
parent | 98eae4e181cb2d1bbc67ec834bfad29dcba7f461 (diff) | |
download | sqlalchemy-aa9cd878e8249a4a758c7f968e929e92fede42a5.tar.gz |
pep-484: session, instancestate, etc
Also adds some fixes to annotation-based mapping
that have come up, as well as starts to add more
pep-484 test cases
Change-Id: Ia722bbbc7967a11b23b66c8084eb61df9d233fee
Diffstat (limited to 'lib/sqlalchemy/ext/asyncio/scoping.py')
-rw-r--r-- | lib/sqlalchemy/ext/asyncio/scoping.py | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/sqlalchemy/ext/asyncio/scoping.py b/lib/sqlalchemy/ext/asyncio/scoping.py index cc5725125..0503076aa 100644 --- a/lib/sqlalchemy/ext/asyncio/scoping.py +++ b/lib/sqlalchemy/ext/asyncio/scoping.py @@ -116,7 +116,7 @@ class async_scoped_session(ScopedSessionMixin): # code within this block is **programmatically, # statically generated** by tools/generate_proxy_methods.py - def __contains__(self, instance): + def __contains__(self, instance: object) -> bool: r"""Return True if the instance is associated with this session. .. container:: class_bases @@ -138,7 +138,7 @@ class async_scoped_session(ScopedSessionMixin): return self._proxied.__contains__(instance) - def __iter__(self): + def __iter__(self) -> Iterator[object]: r"""Iterate over all pending or persistent instances within this Session. @@ -156,7 +156,7 @@ class async_scoped_session(ScopedSessionMixin): return self._proxied.__iter__() - def add(self, instance: Any, _warn: bool = True) -> None: + def add(self, instance: object, _warn: bool = True) -> None: r"""Place an object in the ``Session``. .. container:: class_bases @@ -181,7 +181,7 @@ class async_scoped_session(ScopedSessionMixin): return self._proxied.add(instance, _warn=_warn) - def add_all(self, instances): + def add_all(self, instances: Iterable[object]) -> None: r"""Add the given collection of instances to this ``Session``. .. container:: class_bases @@ -374,7 +374,9 @@ class async_scoped_session(ScopedSessionMixin): **kw, ) - def expire(self, instance, attribute_names=None): + def expire( + self, instance: object, attribute_names: Optional[Iterable[str]] = None + ) -> None: r"""Expire the attributes on an instance. .. container:: class_bases @@ -426,7 +428,7 @@ class async_scoped_session(ScopedSessionMixin): return self._proxied.expire(instance, attribute_names=attribute_names) - def expire_all(self): + def expire_all(self) -> None: r"""Expires all persistent instances within this Session. .. container:: class_bases @@ -473,7 +475,7 @@ class async_scoped_session(ScopedSessionMixin): return self._proxied.expire_all() - def expunge(self, instance): + def expunge(self, instance: object) -> None: r"""Remove the `instance` from this ``Session``. .. container:: class_bases @@ -495,7 +497,7 @@ class async_scoped_session(ScopedSessionMixin): return self._proxied.expunge(instance) - def expunge_all(self): + def expunge_all(self) -> None: r"""Remove all object instances from this ``Session``. .. container:: class_bases @@ -652,7 +654,9 @@ class async_scoped_session(ScopedSessionMixin): mapper=mapper, clause=clause, bind=bind, **kw ) - def is_modified(self, instance, include_collections=True): + def is_modified( + self, instance: object, include_collections: bool = True + ) -> bool: r"""Return ``True`` if the given instance has locally modified attributes. @@ -1168,7 +1172,7 @@ class async_scoped_session(ScopedSessionMixin): return await AsyncSession.close_all() @classmethod - def object_session(cls, instance: Any) -> "Session": + def object_session(cls, instance: object) -> Optional[Session]: r"""Return the :class:`.Session` to which an object belongs. .. container:: class_bases @@ -1192,13 +1196,13 @@ class async_scoped_session(ScopedSessionMixin): @classmethod def identity_key( cls, - class_=None, - ident=None, + class_: Optional[Type[Any]] = None, + ident: Union[Any, Tuple[Any, ...]] = None, *, - instance=None, - row=None, - identity_token=None, - ) -> _IdentityKeyType: + instance: Optional[Any] = None, + row: Optional[Row] = None, + identity_token: Optional[Any] = None, + ) -> _IdentityKeyType[Any]: r"""Return an identity key. .. container:: class_bases |