summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-01-07 01:53:34 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-01-07 01:53:34 +0000
commit84cb9d1f0a3f91fb5e3d4ece78b9ef94d1e5d826 (patch)
tree29ac3a2c6afd6bf14c84358172c4de968ab06304 /lib/sqlalchemy/orm
parent463a5f2e29ca28e53b5d19ac2b63acf39438ce87 (diff)
parent217948f5c79e03956de998af86fef77ebc3edb76 (diff)
downloadsqlalchemy-84cb9d1f0a3f91fb5e3d4ece78b9ef94d1e5d826.tar.gz
Merge "Enable F821"
Diffstat (limited to 'lib/sqlalchemy/orm')
-rw-r--r--lib/sqlalchemy/orm/attributes.py4
-rw-r--r--lib/sqlalchemy/orm/interfaces.py20
-rw-r--r--lib/sqlalchemy/orm/relationships.py9
3 files changed, 24 insertions, 9 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py
index 1805bf8db..66a18da99 100644
--- a/lib/sqlalchemy/orm/attributes.py
+++ b/lib/sqlalchemy/orm/attributes.py
@@ -1586,10 +1586,8 @@ def backref_listeners(attribute, key, uselist):
_NO_HISTORY = util.symbol("NO_HISTORY")
_NO_STATE_SYMBOLS = frozenset([id(PASSIVE_NO_RESULT), id(NO_VALUE)])
-History = util.namedtuple("History", ["added", "unchanged", "deleted"])
-
-class History(History):
+class History(util.namedtuple("History", ["added", "unchanged", "deleted"])):
"""A 3-tuple of added, unchanged and deleted values,
representing the changes which have occurred on an instrumented
attribute.
diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py
index 21479c08b..c7b059fda 100644
--- a/lib/sqlalchemy/orm/interfaces.py
+++ b/lib/sqlalchemy/orm/interfaces.py
@@ -39,6 +39,12 @@ from ..sql import operators
from ..sql import visitors
from ..sql.traversals import HasCacheKey
+if util.TYPE_CHECKING:
+ from typing import Any
+ from typing import List
+ from typing import Optional
+ from .mapper import Mapper
+ from .util import AliasedInsp
__all__ = (
"EXT_CONTINUE",
@@ -363,8 +369,12 @@ class PropComparator(operators.ColumnOperators):
__slots__ = "prop", "property", "_parententity", "_adapt_to_entity"
- def __init__(self, prop, parentmapper, adapt_to_entity=None):
- # type: (MapperProperty, Mapper, Optional(AliasedInsp))
+ def __init__(
+ self,
+ prop, # type: MapperProperty
+ parentmapper, # type: Mapper
+ adapt_to_entity=None, # type: Optional[AliasedInsp]
+ ):
self.prop = self.property = prop
self._parententity = adapt_to_entity or parentmapper
self._adapt_to_entity = adapt_to_entity
@@ -372,8 +382,10 @@ class PropComparator(operators.ColumnOperators):
def __clause_element__(self):
raise NotImplementedError("%r" % self)
- def _bulk_update_tuples(self, value):
- # type: (ColumnOperators) -> List[tuple[ColumnOperators, Any]]
+ def _bulk_update_tuples(
+ self, value # type: (operators.ColumnOperators)
+ ):
+ # type: (...) -> List[tuple[operators.ColumnOperators, Any]]
"""Receive a SQL expression that represents a value in the SET
clause of an UPDATE statement.
diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py
index f1764672c..d745500c1 100644
--- a/lib/sqlalchemy/orm/relationships.py
+++ b/lib/sqlalchemy/orm/relationships.py
@@ -50,6 +50,11 @@ from ..sql.util import selectables_overlap
from ..sql.util import visit_binary_product
+if util.TYPE_CHECKING:
+ from .util import AliasedInsp
+ from typing import Union
+
+
def remote(expr):
"""Annotate a portion of a primaryjoin expression
with a 'remote' annotation.
@@ -1859,9 +1864,9 @@ class RelationshipProperty(StrategizedProperty):
)
@util.memoized_property
- def entity(self): # type: () -> Union[AliasedInsp, Mapper]
+ def entity(self): # type: () -> Union[AliasedInsp, mapperlib.Mapper]
"""Return the target mapped entity, which is an inspect() of the
- class or aliased class tha is referred towards.
+ class or aliased class that is referred towards.
"""
if callable(self.argument) and not isinstance(