From 189039b9d38343b482f1b077bbcf6f6ae99cbacd Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 10 May 2023 11:08:07 -0400 Subject: add full parameter types for ORM with_for_update Fixed typing for the :paramref:`_orm.Session.get.with_for_update` parameter of :meth:`_orm.Session.get` and :meth:`_orm.Session.refresh` (as well as corresponding methods on :class:`_asyncio.AsyncSession`) to accept boolean ``True`` and all other argument forms accepted by the parameter at runtime. Fixes: #9762 Change-Id: Ied4d37a269906b3d9be5ab7d31a2fa863360cced --- lib/sqlalchemy/orm/session.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/orm/session.py') diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index 792b59e81..0ce53bcab 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -126,6 +126,7 @@ if typing.TYPE_CHECKING: from ..sql.base import ExecutableOption from ..sql.elements import ClauseElement from ..sql.roles import TypedColumnsClauseRole + from ..sql.selectable import ForUpdateParameter from ..sql.selectable import TypedReturnsRows _T = TypeVar("_T", bound=Any) @@ -2911,7 +2912,7 @@ class Session(_SessionClassMethods, EventTarget): self, instance: object, attribute_names: Optional[Iterable[str]] = None, - with_for_update: Optional[ForUpdateArg] = None, + with_for_update: ForUpdateParameter = None, ) -> None: """Expire and refresh attributes on the given instance. @@ -3432,7 +3433,7 @@ class Session(_SessionClassMethods, EventTarget): *, options: Optional[Sequence[ORMOption]] = None, populate_existing: bool = False, - with_for_update: Optional[ForUpdateArg] = None, + with_for_update: ForUpdateParameter = None, identity_token: Optional[Any] = None, execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT, bind_arguments: Optional[_BindArguments] = None, @@ -3559,7 +3560,7 @@ class Session(_SessionClassMethods, EventTarget): *, options: Optional[Sequence[ExecutableOption]] = None, populate_existing: bool = False, - with_for_update: Optional[ForUpdateArg] = None, + with_for_update: ForUpdateParameter = None, identity_token: Optional[Any] = None, execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT, bind_arguments: Optional[_BindArguments] = None, -- cgit v1.2.1