diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-01-06 01:19:47 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-01-06 18:23:11 -0500 |
commit | 1e278de4cc9a4181e0747640a960e80efcea1ca9 (patch) | |
tree | 13d0c035807613bfa07e734acad79b9c843cb8b0 /lib/sqlalchemy/orm/query.py | |
parent | 1e1a38e7801f410f244e4bbb44ec795ae152e04e (diff) | |
download | sqlalchemy-1e278de4cc9a4181e0747640a960e80efcea1ca9.tar.gz |
Post black reformatting
Applied on top of a pure run of black -l 79 in
I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes
resolves all remaining flake8 conditions for those codes
we have enabled in setup.cfg.
Included are resolutions for all remaining flake8 issues
including shadowed builtins, long lines, import order, unused
imports, duplicate imports, and docstring issues.
Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
Diffstat (limited to 'lib/sqlalchemy/orm/query.py')
-rw-r--r-- | lib/sqlalchemy/orm/query.py | 93 |
1 files changed, 49 insertions, 44 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 4a55a3247..a4dddcd23 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -21,36 +21,39 @@ database to return iterable result sets. from itertools import chain -from . import ( - attributes, - interfaces, - object_mapper, - persistence, - exc as orm_exc, - loading, -) -from .base import ( - _entity_descriptor, - _is_aliased_class, - _is_mapped_class, - _orm_columns, - _generative, - InspectionAttr, -) +from . import attributes +from . import exc as orm_exc +from . import interfaces +from . import loading +from . import persistence +from . import properties +from .base import _entity_descriptor +from .base import _generative +from .base import _is_aliased_class +from .base import _is_mapped_class +from .base import _orm_columns +from .base import InspectionAttr from .path_registry import PathRegistry -from .util import ( - AliasedClass, - ORMAdapter, - join as orm_join, - with_parent, - aliased, - _entity_corresponds_to, -) -from .. import sql, util, log, exc as sa_exc, inspect, inspection -from ..sql.expression import _interpret_as_from -from ..sql import util as sql_util, expression, visitors +from .util import _entity_corresponds_to +from .util import aliased +from .util import AliasedClass +from .util import join as orm_join +from .util import object_mapper +from .util import ORMAdapter +from .util import with_parent +from .. import exc as sa_exc +from .. import inspect +from .. import inspection +from .. import log +from .. import sql +from .. import util +from ..sql import expression +from ..sql import util as sql_util +from ..sql import visitors from ..sql.base import ColumnCollection -from . import properties +from ..sql.expression import _interpret_as_from +from ..sql.selectable import ForUpdateArg + __all__ = ["Query", "QueryContext", "aliased"] @@ -1103,7 +1106,7 @@ class Query(object): """ self._invoke_all_eagers = value - def with_parent(self, instance, property=None, from_entity=None): + def with_parent(self, instance, property=None, from_entity=None): # noqa """Add filtering criterion that relates the given instance to a child object or collection, using its attribute state as well as an established :func:`.relationship()` @@ -1143,7 +1146,7 @@ class Query(object): isinstance(prop, properties.RelationshipProperty) and prop.mapper is entity_zero.mapper ): - property = prop + property = prop # noqa break else: raise sa_exc.InvalidRequestError( @@ -2397,17 +2400,20 @@ class Query(object): # figure out the best "left" side based on our existing froms / # entities assert prop is None - left, replace_from_obj_index, use_entity_index = self._join_determine_implicit_left_side( - left, right, onclause - ) + ( + left, + replace_from_obj_index, + use_entity_index, + ) = self._join_determine_implicit_left_side(left, right, onclause) else: # left is given via a relationship/name. Determine where in our # "froms" list it should be spliced/appended as well as what # existing entity it corresponds to. assert prop is not None - replace_from_obj_index, use_entity_index = self._join_place_explicit_left_side( - left - ) + ( + replace_from_obj_index, + use_entity_index, + ) = self._join_place_explicit_left_side(left) # this should never happen because we would not have found a place # to join on @@ -3153,7 +3159,8 @@ class Query(object): (note this may consist of multiple result rows if join-loaded collections are present). - Calling :meth:`.Query.first` results in an execution of the underlying query. + Calling :meth:`.Query.first` results in an execution of the underlying + query. .. seealso:: @@ -3665,7 +3672,8 @@ class Query(object): values or sql expressions as values. If :ref:`parameter-ordered mode <updates_order_parameters>` is desired, the values can be passed as a list of 2-tuples; - this requires that the :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order` + this requires that the + :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order` flag is passed to the :paramref:`.Query.update.update_args` dictionary as well. @@ -3905,9 +3913,9 @@ class Query(object): context.order_by = None if self._distinct is True and context.order_by: - context.primary_columns += sql_util.expand_column_list_from_order_by( - context.primary_columns, context.order_by - ) + context.primary_columns += ( + sql_util.expand_column_list_from_order_by + )(context.primary_columns, context.order_by) context.froms += tuple(context.eager_joins.values()) statement = sql.select( @@ -3966,9 +3974,6 @@ class Query(object): ) -from ..sql.selectable import ForUpdateArg - - class LockmodeArg(ForUpdateArg): @classmethod def parse_legacy_query(self, mode): |