diff options
Diffstat (limited to 'lib/sqlalchemy/ext')
| -rw-r--r-- | lib/sqlalchemy/ext/associationproxy.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/automap.py | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/baked.py | 30 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/horizontal_shard.py | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/indexable.py | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/instrumentation.py | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/mypy/apply.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/mypy/util.py | 5 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/orderinglist.py | 20 |
9 files changed, 38 insertions, 47 deletions
diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index bfec09137..f4adf3d29 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -1071,7 +1071,7 @@ class AmbiguousAssociationProxyInstance(AssociationProxyInstance[_T]): if obj is None: return self else: - return super(AmbiguousAssociationProxyInstance, self).get(obj) + return super().get(obj) def __eq__(self, obj: object) -> NoReturn: self._ambiguous() diff --git a/lib/sqlalchemy/ext/automap.py b/lib/sqlalchemy/ext/automap.py index 6d441c9e3..6eb30ba4c 100644 --- a/lib/sqlalchemy/ext/automap.py +++ b/lib/sqlalchemy/ext/automap.py @@ -884,12 +884,12 @@ class AutomapBase: cls.metadata.reflect(autoload_with, **opts) with _CONFIGURE_MUTEX: - table_to_map_config = dict( - (m.local_table, m) + table_to_map_config = { + m.local_table: m for m in _DeferredMapperConfig.classes_for_base( cls, sort=False ) - ) + } many_to_many = [] diff --git a/lib/sqlalchemy/ext/baked.py b/lib/sqlalchemy/ext/baked.py index 7093de732..48e57e2bc 100644 --- a/lib/sqlalchemy/ext/baked.py +++ b/lib/sqlalchemy/ext/baked.py @@ -525,15 +525,13 @@ class Result: # None present in ident - turn those comparisons # into "IS NULL" if None in primary_key_identity: - nones = set( - [ - _get_params[col].key - for col, value in zip( - mapper.primary_key, primary_key_identity - ) - if value is None - ] - ) + nones = { + _get_params[col].key + for col, value in zip( + mapper.primary_key, primary_key_identity + ) + if value is None + } _lcl_get_clause = sql_util.adapt_criterion_to_null( _lcl_get_clause, nones ) @@ -562,14 +560,12 @@ class Result: setup, tuple(elem is None for elem in primary_key_identity) ) - params = dict( - [ - (_get_params[primary_key].key, id_val) - for id_val, primary_key in zip( - primary_key_identity, mapper.primary_key - ) - ] - ) + params = { + _get_params[primary_key].key: id_val + for id_val, primary_key in zip( + primary_key_identity, mapper.primary_key + ) + } result = list(bq.for_session(self.session).params(**params)) l = len(result) diff --git a/lib/sqlalchemy/ext/horizontal_shard.py b/lib/sqlalchemy/ext/horizontal_shard.py index 7afe2343d..8f6e2ffcd 100644 --- a/lib/sqlalchemy/ext/horizontal_shard.py +++ b/lib/sqlalchemy/ext/horizontal_shard.py @@ -28,7 +28,7 @@ __all__ = ["ShardedSession", "ShardedQuery"] class ShardedQuery(Query): def __init__(self, *args, **kwargs): - super(ShardedQuery, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.id_chooser = self.session.id_chooser self.query_chooser = self.session.query_chooser self.execute_chooser = self.session.execute_chooser @@ -88,7 +88,7 @@ class ShardedSession(Session): """ query_chooser = kwargs.pop("query_chooser", None) - super(ShardedSession, self).__init__(query_cls=query_cls, **kwargs) + super().__init__(query_cls=query_cls, **kwargs) event.listen( self, "do_orm_execute", execute_and_instances, retval=True @@ -138,7 +138,7 @@ class ShardedSession(Session): """ if identity_token is not None: - return super(ShardedSession, self)._identity_lookup( + return super()._identity_lookup( mapper, primary_key_identity, identity_token=identity_token, @@ -149,7 +149,7 @@ class ShardedSession(Session): if lazy_loaded_from: q = q._set_lazyload_from(lazy_loaded_from) for shard_id in self.id_chooser(q, primary_key_identity): - obj = super(ShardedSession, self)._identity_lookup( + obj = super()._identity_lookup( mapper, primary_key_identity, identity_token=shard_id, diff --git a/lib/sqlalchemy/ext/indexable.py b/lib/sqlalchemy/ext/indexable.py index 5c5d26736..ce6312365 100644 --- a/lib/sqlalchemy/ext/indexable.py +++ b/lib/sqlalchemy/ext/indexable.py @@ -278,13 +278,9 @@ class index_property(hybrid_property): # noqa """ if mutable: - super(index_property, self).__init__( - self.fget, self.fset, self.fdel, self.expr - ) + super().__init__(self.fget, self.fset, self.fdel, self.expr) else: - super(index_property, self).__init__( - self.fget, None, None, self.expr - ) + super().__init__(self.fget, None, None, self.expr) self.attr_name = attr_name self.index = index self.default = default diff --git a/lib/sqlalchemy/ext/instrumentation.py b/lib/sqlalchemy/ext/instrumentation.py index 427e151da..f36087ad9 100644 --- a/lib/sqlalchemy/ext/instrumentation.py +++ b/lib/sqlalchemy/ext/instrumentation.py @@ -165,7 +165,7 @@ class ExtendedInstrumentationRegistry(InstrumentationFactory): return factories def unregister(self, class_): - super(ExtendedInstrumentationRegistry, self).unregister(class_) + super().unregister(class_) if class_ in self._manager_finders: del self._manager_finders[class_] del self._state_finders[class_] @@ -321,7 +321,7 @@ class _ClassInstrumentationAdapter(ClassManager): self._adapted.instrument_attribute(self.class_, key, inst) def post_configure_attribute(self, key): - super(_ClassInstrumentationAdapter, self).post_configure_attribute(key) + super().post_configure_attribute(key) self._adapted.post_configure_attribute(self.class_, key, self[key]) def install_descriptor(self, key, inst): diff --git a/lib/sqlalchemy/ext/mypy/apply.py b/lib/sqlalchemy/ext/mypy/apply.py index bfc3459d0..f392a85a7 100644 --- a/lib/sqlalchemy/ext/mypy/apply.py +++ b/lib/sqlalchemy/ext/mypy/apply.py @@ -63,7 +63,7 @@ def apply_mypy_mapped_attr( ): break else: - util.fail(api, "Can't find mapped attribute {}".format(name), cls) + util.fail(api, f"Can't find mapped attribute {name}", cls) return None if stmt.type is None: diff --git a/lib/sqlalchemy/ext/mypy/util.py b/lib/sqlalchemy/ext/mypy/util.py index 44a1768a8..a32bc9b52 100644 --- a/lib/sqlalchemy/ext/mypy/util.py +++ b/lib/sqlalchemy/ext/mypy/util.py @@ -90,7 +90,7 @@ class SQLAlchemyAttribute: info: TypeInfo, data: JsonDict, api: SemanticAnalyzerPluginInterface, - ) -> "SQLAlchemyAttribute": + ) -> SQLAlchemyAttribute: data = data.copy() typ = deserialize_and_fixup_type(data.pop("type"), api) return cls(typ=typ, info=info, **data) @@ -238,8 +238,7 @@ def flatten_typechecking(stmts: Iterable[Statement]) -> Iterator[Statement]: and isinstance(stmt.expr[0], NameExpr) and stmt.expr[0].fullname == "typing.TYPE_CHECKING" ): - for substmt in stmt.body[0].body: - yield substmt + yield from stmt.body[0].body else: yield stmt diff --git a/lib/sqlalchemy/ext/orderinglist.py b/lib/sqlalchemy/ext/orderinglist.py index f08ffc68d..b0615d95d 100644 --- a/lib/sqlalchemy/ext/orderinglist.py +++ b/lib/sqlalchemy/ext/orderinglist.py @@ -143,7 +143,7 @@ def ordering_list( count_from: Optional[int] = None, ordering_func: Optional[OrderingFunc] = None, reorder_on_append: bool = False, -) -> Callable[[], "OrderingList"]: +) -> Callable[[], OrderingList]: """Prepares an :class:`OrderingList` factory for use in mapper definitions. Returns an object suitable for use as an argument to a Mapper @@ -335,29 +335,29 @@ class OrderingList(List[_T]): self._set_order_value(entity, should_be) def append(self, entity): - super(OrderingList, self).append(entity) + super().append(entity) self._order_entity(len(self) - 1, entity, self.reorder_on_append) def _raw_append(self, entity): """Append without any ordering behavior.""" - super(OrderingList, self).append(entity) + super().append(entity) _raw_append = collection.adds(1)(_raw_append) def insert(self, index, entity): - super(OrderingList, self).insert(index, entity) + super().insert(index, entity) self._reorder() def remove(self, entity): - super(OrderingList, self).remove(entity) + super().remove(entity) adapter = collection_adapter(self) if adapter and adapter._referenced_by_owner: self._reorder() def pop(self, index=-1): - entity = super(OrderingList, self).pop(index) + entity = super().pop(index) self._reorder() return entity @@ -375,18 +375,18 @@ class OrderingList(List[_T]): self.__setitem__(i, entity[i]) else: self._order_entity(index, entity, True) - super(OrderingList, self).__setitem__(index, entity) + super().__setitem__(index, entity) def __delitem__(self, index): - super(OrderingList, self).__delitem__(index) + super().__delitem__(index) self._reorder() def __setslice__(self, start, end, values): - super(OrderingList, self).__setslice__(start, end, values) + super().__setslice__(start, end, values) self._reorder() def __delslice__(self, start, end): - super(OrderingList, self).__delslice__(start, end) + super().__delslice__(start, end) self._reorder() def __reduce__(self): |
