]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Fix inferred type of async_sessionmaker
authorSam Bull <aa6bs0@sambull.org>
Sun, 20 Nov 2022 00:38:04 +0000 (19:38 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 21 Nov 2022 17:01:56 +0000 (12:01 -0500)
commite43e240a0088ac429eb551c7ea1c537c266b4853
tree7a5604931823414fc133cf04b04e4f6607904b7c
parent46e6693cb3db445f18aa25d5e4ca613504bd12b3
Fix inferred type of async_sessionmaker

Improved the typing for :class:`.sessionmaker` and
:class:`.asyncsessionmaker`, so that the default type of their return value
will be :class:`.Session` or :class:`.AsyncSession`, without the need to
type this explicitly. Previously, Mypy would not automaticaly infer these
return types from its generic base.

As part of this change, arguments for :class:`.Session`,
:class:`.AsyncSession`, :class:`.sessionmaker` and
:class:`.asyncsessionmaker` beyond the initial "bind" argument have been
made keyword-only, which includes parameters that have always been
documented as keyword arguments, such as :paramref:`.Session.autoflush`,
:paramref:`.Session.class_`, etc.

Pull request courtesy Sam Bull.

Closes: #8842
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8842
Pull-request-sha: fa6d1a8468e98b40e12f82ed7ddaddc1fde060ac

Change-Id: Iaaabc4572a87489d61617d970f62b9b50db4fac7
doc/build/changelog/unreleased_20/8842.rst [new file with mode: 0644]
lib/sqlalchemy/ext/asyncio/session.py
lib/sqlalchemy/orm/session.py
test/ext/mypy/plain_files/sessionmakers.py