diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-04-15 11:05:36 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-04-20 15:14:09 -0400 |
commit | aeeff72e806420bf85e2e6723b1f941df38a3e1a (patch) | |
tree | 0bed521b4d7c4860f998e51ba5e318d18b2f5900 /lib/sqlalchemy/orm/attributes.py | |
parent | 13a8552053c21a9fa7ff6f992ed49ee92cca73e4 (diff) | |
download | sqlalchemy-aeeff72e806420bf85e2e6723b1f941df38a3e1a.tar.gz |
pep-484: ORM public API, constructors
for the moment, abandoning using @overload with
relationship() and mapped_column(). The overloads
are very difficult to get working at all, and
the overloads that were there all wouldn't pass on
mypy. various techniques of getting them to
"work", meaning having right hand side dictate
what's legal on the left, have mixed success
and wont give consistent results; additionally,
it's legal to have Optional / non-optional
independent of nullable in any case for columns.
relationship cases are less ambiguous but mypy
was not going along with things.
we have a comprehensive system of allowing
left side annotations to drive the right side,
in the absense of explicit settings on the right.
so type-centric SQLAlchemy will be left-side
driven just like dataclasses, and the various flags
and switches on the right side will just not be
needed very much.
in other matters, one surprise, forgot to remove string support
from orm.join(A, B, "somename") or do deprecations
for it in 1.4. This is a really not-directly-used
structure barely
mentioned in the docs for many years, the example
shows a relationship being used, not a string, so
we will just change it to raise the usual error here.
Change-Id: Iefbbb8d34548b538023890ab8b7c9a5d9496ec6e
Diffstat (limited to 'lib/sqlalchemy/orm/attributes.py')
-rw-r--r-- | lib/sqlalchemy/orm/attributes.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index 33ce96a19..41d944c57 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -44,7 +44,7 @@ from .base import instance_dict as instance_dict from .base import instance_state as instance_state from .base import instance_str from .base import LOAD_AGAINST_COMMITTED -from .base import manager_of_class +from .base import manager_of_class as manager_of_class from .base import Mapped as Mapped # noqa from .base import NEVER_SET # noqa from .base import NO_AUTOFLUSH @@ -52,6 +52,7 @@ from .base import NO_CHANGE # noqa from .base import NO_RAISE from .base import NO_VALUE from .base import NON_PERSISTENT_OK # noqa +from .base import opt_manager_of_class as opt_manager_of_class from .base import PASSIVE_CLASS_MISMATCH # noqa from .base import PASSIVE_NO_FETCH from .base import PASSIVE_NO_FETCH_RELATED # noqa @@ -74,6 +75,7 @@ from ..sql import traversals from ..sql import visitors if TYPE_CHECKING: + from .interfaces import MapperProperty from .state import InstanceState from ..sql.dml import _DMLColumnElement from ..sql.elements import ColumnElement @@ -146,7 +148,7 @@ class QueryableAttribute( self._of_type = of_type self._extra_criteria = extra_criteria - manager = manager_of_class(class_) + manager = opt_manager_of_class(class_) # manager is None in the case of AliasedClass if manager: # propagate existing event listeners from @@ -370,7 +372,7 @@ class QueryableAttribute( return "%s.%s" % (self.class_.__name__, self.key) @util.memoized_property - def property(self): + def property(self) -> MapperProperty[_T]: """Return the :class:`.MapperProperty` associated with this :class:`.QueryableAttribute`. |