]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
reorganize Mapped[] super outside of MapperProperty
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 29 Sep 2022 16:56:23 +0000 (12:56 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 6 Oct 2022 00:35:57 +0000 (20:35 -0400)
commit566cccc8645be99a23811c39d43481d7248628b0
tree15bad7e506967108c0f2e8aec626e8eebd6ff1fc
parent3ab59694dbe04bf967e9af18d1ae49e1c5ea44ed
reorganize Mapped[] super outside of MapperProperty

We made all the MapperProperty classes a subclass
of Mapped[] to allow declarative mappings to name
Mapped[] on the left side.  this was cheating a bit because
MapperProperty is not actually a descriptor, and the mapping
process replaces the object with InstrumentedAttribute at
mapping time, which is the actual Mapped[] descriptor.

But now in I6929f3da6e441cad92285e7309030a9bac4e429d we
are considering making the "cheating" a little more extensive
by putting DynamicMapped / WriteOnlyMapped in Relationship's
hierarchy, which need a flat out "type: ignore" to work.

Instead of pushing more cheats into the core classes, move
out the "Declarative"-facing versions of these classes to be
typing only: Relationship, Composite, Synonym, and MappedSQLExpression
added for ColumnProperty.  Keep the internals expressed on the
old names, RelationshipProperty, CompositeProperty, SynonymProperty,
ColumnProprerty, which will remain "pure" with fully correct typing.
then have the typing only endpoints be where the "cheating"
and "type: ignores" have to happen, so that these are more or less
slightly better forms of "Any".

Change-Id: Ied7cc11196c9204da6851f49593d1b1fd2ef8ad8
31 files changed:
doc/build/changelog/unreleased_14/8588.rst
doc/build/orm/internals.rst
lib/sqlalchemy/ext/associationproxy.py
lib/sqlalchemy/ext/declarative/extensions.py
lib/sqlalchemy/ext/mypy/names.py
lib/sqlalchemy/orm/__init__.py
lib/sqlalchemy/orm/_orm_constructors.py
lib/sqlalchemy/orm/_typing.py
lib/sqlalchemy/orm/attributes.py
lib/sqlalchemy/orm/base.py
lib/sqlalchemy/orm/clsregistry.py
lib/sqlalchemy/orm/decl_api.py
lib/sqlalchemy/orm/decl_base.py
lib/sqlalchemy/orm/descriptor_props.py
lib/sqlalchemy/orm/dynamic.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/orm/path_registry.py
lib/sqlalchemy/orm/properties.py
lib/sqlalchemy/orm/query.py
lib/sqlalchemy/orm/relationships.py
lib/sqlalchemy/orm/strategies.py
lib/sqlalchemy/orm/util.py
lib/sqlalchemy/util/__init__.py
lib/sqlalchemy/util/langhelpers.py
test/ext/mypy/plugin_files/mixin_two.py
test/ext/mypy/plugin_files/typing_err2.py
test/orm/declarative/test_basic.py
test/orm/test_mapper.py
test/orm/test_options.py
test/orm/test_rel_fn.py