Some `__slots__` were not in order.
Fixes #7527
### Description
I'm fixing two types of slots mistakes:
- [x] remove overlapping slots (i.e. slots already defined on a base class)
- [x] fix broken inheritance (i.e. slots class inheriting from a non-slots class)
- [x] slots added to base class `TransactionalContext`. It seemed to use two attributes, which I've added as slots.
- [x] empty slots removed from `ORMOption`. Its base class explicitly makes use of `__dict__` so empty slots don't add anything.
- [x] empty slots added to `PostLoader`. It doesn't appear to use any slots not already defined on its base classes.
- [x] empty slots added to `IterateMappersMixin`. It doesn't appear to use any slots not already defined on its subclasses.
- [x] empty slots added to `ImmutableContainer`. It doesn't use any fields.
- [x] empty slots added to `OperatorType`. It's a protocol.
- [x] empty slots added to `InternalTraversal`, `_HasTraversalDispatch`. They don't seem to use attributes on their own.
### Checklist
This pull request is:
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests. one line code fixes without tests will not be accepted.
**Have a nice day!**
Closes: #7589
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7589
Pull-request-sha:
70a9c4d46916b7c6907eb1d3ad4f7033ec964191
Change-Id: I6c6e3e69c3c34d0f3bdda7f0684849834fdd1863
class ImmutableContainer:
+
+ __slots__ = ()
+
def _immutable(self, *a,**kw):
_immutable_fn(self)
class AsyncAdapt_aiomysql_connection(AdaptedConnection):
await_ = staticmethod(await_only)
- __slots__ = ("dbapi", "_connection", "_execute_mutex")
+ __slots__ = ("dbapi", "_execute_mutex")
def __init__(self, dbapi, connection):
self.dbapi = dbapi
class AsyncAdapt_aiosqlite_connection(AdaptedConnection):
await_ = staticmethod(await_only)
- __slots__ = ("dbapi", "_connection")
+ __slots__ = ("dbapi",)
def __init__(self, dbapi, connection):
self.dbapi = dbapi
"""
- __slots__ = ("connection", "is_active", "xid", "_is_prepared")
+ __slots__ = ("xid", "_is_prepared")
def __init__(self, connection, xid):
self._is_prepared = False
collections_abc.ValuesView,
collections_abc.ItemsView,
):
- __slots__ = (
- "_mapping",
- "_items",
- )
+ __slots__ = ("_items",)
def __init__(self, mapping, items):
self._mapping = mapping
"""
- _trans_subject = None
+ __slots__ = ("_outer_trans_ctx", "_trans_subject", "__weakref__")
def _transaction_is_active(self):
raise NotImplementedError()
return self
def __exit__(self, type_, value, traceback):
- subject = self._trans_subject
+ subject = getattr(self, "_trans_subject", None)
# simplistically we could assume that
# "subject._trans_context_manager is self". However, any calling
"descriptor",
"active_history",
"expire_on_flush",
- "info",
"doc",
"strategy_key",
"_creation_order",
class PostLoader(AbstractRelationshipLoader):
"""A relationship loader that emits a second SELECT statement."""
+ __slots__ = ()
+
def _check_recursive_postload(self, context, path, join_depth=None):
effective_path = (
context.compile_state.current_path or orm_util.PathRegistry.root
class IterateMappersMixin:
+
+ __slots__ = ()
+
def _mappers(self, uow):
if self.fromparent:
return iter(
class Options(metaclass=_MetaOptions):
"""A cacheable option dictionary with defaults."""
+ __slots__ = ()
+
def __init_subclass__(cls) -> None:
dict_ = cls.__dict__
cls._cache_attrs = tuple(
class OperatorType(Protocol):
"""describe an op() function."""
+ __slots__ = ()
+
__name__: str
def __call__(
"""
+ __slots__ = ()
+
def __init_subclass__(cls) -> None:
cls._generate_traversal_dispatch()
super().__init_subclass__()
"""
+ __slots__ = ()
+
dp_has_cache_key = symbol("HC")
"""Visit a :class:`.HasCacheKey` object."""
"""
+ __slots__ = ()
+
dp_ignore = symbol("IG")
"""Specify an object that should be ignored entirely.