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/sql/base.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/sql/base.py')
-rw-r--r-- | lib/sqlalchemy/sql/base.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index f7692dbc2..f81878d55 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -218,7 +218,7 @@ def _generative(fn: _Fn) -> _Fn: """ - @util.decorator + @util.decorator # type: ignore def _generative( fn: _Fn, self: _SelfGenerativeType, *args: Any, **kw: Any ) -> _SelfGenerativeType: @@ -244,7 +244,7 @@ def _exclusive_against(*names: str, **kw: Any) -> Callable[[_Fn], _Fn]: for name in names ] - @util.decorator + @util.decorator # type: ignore def check(fn, *args, **kw): # make pylance happy by not including "self" in the argument # list @@ -260,7 +260,7 @@ def _exclusive_against(*names: str, **kw: Any) -> Callable[[_Fn], _Fn]: raise exc.InvalidRequestError(msg) return fn(self, *args, **kw) - return check + return check # type: ignore def _clone(element, **kw): @@ -1750,15 +1750,14 @@ class DedupeColumnCollection(ColumnCollection[str, _NAMEDCOL]): self._collection.append((k, col)) self._colset.update(c for (k, c) in self._collection) - # https://github.com/python/mypy/issues/12610 self._index.update( - (idx, c) for idx, (k, c) in enumerate(self._collection) # type: ignore # noqa: E501 + (idx, c) for idx, (k, c) in enumerate(self._collection) ) for col in replace_col: self.replace(col) def extend(self, iter_: Iterable[_NAMEDCOL]) -> None: - self._populate_separate_keys((col.key, col) for col in iter_) # type: ignore # noqa: E501 + self._populate_separate_keys((col.key, col) for col in iter_) def remove(self, column: _NAMEDCOL) -> None: if column not in self._colset: @@ -1772,9 +1771,8 @@ class DedupeColumnCollection(ColumnCollection[str, _NAMEDCOL]): (k, c) for (k, c) in self._collection if c is not column ] - # https://github.com/python/mypy/issues/12610 self._index.update( - {idx: col for idx, (k, col) in enumerate(self._collection)} # type: ignore # noqa: E501 + {idx: col for idx, (k, col) in enumerate(self._collection)} ) # delete higher index del self._index[len(self._collection)] @@ -1827,9 +1825,8 @@ class DedupeColumnCollection(ColumnCollection[str, _NAMEDCOL]): self._index.clear() - # https://github.com/python/mypy/issues/12610 self._index.update( - {idx: col for idx, (k, col) in enumerate(self._collection)} # type: ignore # noqa: E501 + {idx: col for idx, (k, col) in enumerate(self._collection)} ) self._index.update(self._collection) |