diff options
| author | Arie Bovenberg <a.c.bovenberg@gmail.com> | 2022-02-01 15:08:19 -0500 |
|---|---|---|
| committer | sqla-tester <sqla-tester@sqlalchemy.org> | 2022-02-01 15:08:19 -0500 |
| commit | 0409c88c297efa324218340b265a8d107d57deee (patch) | |
| tree | 2337be6a74df17bd189a89a4c21254a50ed2d8ad /lib/sqlalchemy/sql | |
| parent | d6046f5fcf3732df1a8a08274501efcffc6253f2 (diff) | |
| download | sqlalchemy-0409c88c297efa324218340b265a8d107d57deee.tar.gz | |
Fix overlapping slots, base classes without slots
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
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/base.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/operators.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/visitors.py | 6 |
3 files changed, 10 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index 8ae8f8f65..f4fe7afab 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -639,6 +639,8 @@ class _MetaOptions(type): class Options(metaclass=_MetaOptions): """A cacheable option dictionary with defaults.""" + __slots__ = () + def __init_subclass__(cls) -> None: dict_ = cls.__dict__ cls._cache_attrs = tuple( diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py index cf61f2637..255e77b7f 100644 --- a/lib/sqlalchemy/sql/operators.py +++ b/lib/sqlalchemy/sql/operators.py @@ -57,6 +57,8 @@ _T = TypeVar("_T", bound=Any) class OperatorType(Protocol): """describe an op() function.""" + __slots__ = () + __name__: str def __call__( diff --git a/lib/sqlalchemy/sql/visitors.py b/lib/sqlalchemy/sql/visitors.py index 78384782b..640c07d61 100644 --- a/lib/sqlalchemy/sql/visitors.py +++ b/lib/sqlalchemy/sql/visitors.py @@ -184,6 +184,8 @@ class _HasTraversalDispatch: """ + __slots__ = () + def __init_subclass__(cls) -> None: cls._generate_traversal_dispatch() super().__init_subclass__() @@ -299,6 +301,8 @@ class InternalTraversal(_HasTraversalDispatch): """ + __slots__ = () + dp_has_cache_key = symbol("HC") """Visit a :class:`.HasCacheKey` object.""" @@ -504,6 +508,8 @@ class ExtendedInternalTraversal(InternalTraversal): """ + __slots__ = () + dp_ignore = symbol("IG") """Specify an object that should be ignored entirely. |
