]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
liberalize pep695 matching
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 4 Sep 2025 01:44:33 +0000 (21:44 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 6 Sep 2025 16:13:49 +0000 (12:13 -0400)
commitadef2eb884e6d7235b519625443aaf14e4821a05
tree5efb8f3e43ab152b7b81faa9347576593b79c939
parenteebd3019bd28a2f2cd4019ea21383ab54fa9feae
liberalize pep695 matching

after many days of discussion we are moving to liberalize the
matching rules used for pep695 to the simple rule that we will resolve
a pep695 type to its immediate ``__value__`` without requiring that
it be present in the type map, however without any further recursive
checks (that is, we will not resolve ``__value__`` of ``__value__``).
This allows the vast majority of simple uses of pep695 types to not
require entries in the type map, including when the type points
to a simple Python type or any type that is present in the type_map.
Also supported is resolution of generic pep695 types against the
right side, including for Annotated types.

The change here in 2.1 will form the base for a revised approach
to the RegistryEvents patch for #9832, which will still provide
the RegistryEvents.resolve_type_annotation hook.   In 2.0, we need
to scale back the warnings that are emitted so portions of this patch
will also be backported including similar changes to the test suite.

Fixes: #12829
Change-Id: Ib6e379793335da3f33f6ca2cd6874a6eaf1e36f4
(cherry picked from commit f44a361d18c57167622c34c04c6e2e1b67b1c9f2)
doc/build/changelog/changelog_20.rst
doc/build/changelog/unreleased_20/12829.rst [new file with mode: 0644]
doc/build/orm/declarative_tables.rst
lib/sqlalchemy/orm/decl_api.py
lib/sqlalchemy/orm/properties.py
lib/sqlalchemy/util/typing.py
test/orm/declarative/test_tm_future_annotations_sync.py
test/orm/declarative/test_typed_mapping.py