Several classes have __slots__, but not their bases do not · Issue #7527 · sqlalchemy/sqlalchemy · GitHub
Skip to content

Several classes have __slots__, but not their bases do not #7527

Description

@ariebovenberg

Describe the bug

Quite a few classes define __slots__, but have bases where __slots__ is not defined:

ERROR: 'sqlalchemy.engine.base.Transaction' has slots but inherits from non-slot class
ERROR: 'sqlalchemy.orm.interfaces.ORMOption' has slots but inherits from non-slot class
ERROR: 'sqlalchemy.orm.strategies.ImmediateLoader' has slots but inherits from non-slot class
ERROR: 'sqlalchemy.orm.strategies.SelectInLoader' has slots but inherits from non-slot class
ERROR: 'sqlalchemy.orm.strategies.SubqueryLoader' has slots but inherits from non-slot class
ERROR: 'sqlalchemy.orm.unitofwork.Preprocess' has slots but inherits from non-slot class
ERROR: 'sqlalchemy.orm.unitofwork.ProcessAll' has slots but inherits from non-slot class
ERROR: 'sqlalchemy.sql.base.ImmutableColumnCollection' has slots but inherits from non-slot class
ERROR: 'sqlalchemy.sql.coercions.ByOfImpl' has slots but inherits from non-slot class
ERROR: 'sqlalchemy.sql.compiler._CompileLabel' has slots but inherits from non-slot class
ERROR: 'sqlalchemy.sql.roles.ExecutableOptionRole' has slots but inherits from non-slot class
ERROR: 'sqlalchemy.sql.traversals.TraversalComparatorStrategy' has slots but inherits from non-slot class
ERROR: 'sqlalchemy.util._collections.ImmutableProperties' has slots but inherits from non-slot class

"slotless" base classes causing this:

       - sqlalchemy.engine.util.TransactionalContext
       - sqlalchemy.orm.strategies.PostLoader
       - sqlalchemy.orm.unitofwork.IterateMappersMixin
       - sqlalchemy.sql.annotation.SupportsAnnotations
       - sqlalchemy.sql.annotation.SupportsWrappingAnnotations
       - sqlalchemy.sql.base.ExecutableOption
       - sqlalchemy.sql.elements.ClauseElement
       - sqlalchemy.sql.elements.ColumnElement
       - sqlalchemy.sql.roles.AllowsLambdaRole
       - sqlalchemy.sql.roles.BinaryElementRole
       - sqlalchemy.sql.roles.ByOfRole
       - sqlalchemy.sql.roles.ColumnArgumentOrKeyRole
       - sqlalchemy.sql.roles.ColumnArgumentRole
       - sqlalchemy.sql.roles.ColumnListRole
       - sqlalchemy.sql.roles.ColumnsClauseRole
       - sqlalchemy.sql.roles.DDLConstraintColumnRole
       - sqlalchemy.sql.roles.DDLExpressionRole
       - sqlalchemy.sql.roles.DMLColumnRole
       - sqlalchemy.sql.roles.ExpressionElementRole
       - sqlalchemy.sql.roles.LimitOffsetRole
       - sqlalchemy.sql.roles.OnClauseRole
       - sqlalchemy.sql.roles.OrderByRole
       - sqlalchemy.sql.roles.SQLRole
       - sqlalchemy.sql.roles.StatementOptionRole
       - sqlalchemy.sql.roles.StructuralRole
       - sqlalchemy.sql.roles.UsesInspection
       - sqlalchemy.sql.roles.WhereHavingRole
       - sqlalchemy.sql.traversals.HasCopyInternals
       - sqlalchemy.sql.traversals.MemoizedHasCacheKey
       - sqlalchemy.sql.visitors.InternalTraversal
       - sqlalchemy.sql.visitors.Traversible
       - sqlalchemy.util._collections.ImmutableContainer

To Reproduce

>>> # just an example of one of the classes with ineffective __slots__
>>> from sqlalchemy.orm.interfaces import ORMOption
>>> ORMOption().__dict__
{}

Error

There should not be a __dict__ on properly __slot__ed classes.

Versions

  • OS: MacOS
  • Python: 3.10
  • SQLAlchemy: 1.4.29
  • Database: n/a
  • DBAPI (eg: psycopg, cx_oracle, mysqlclient): n/a

Additional context

If you agree, I'd like to investigate and fix this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingperformancewhere performance can be improved. add "bug" only if it's a performance degradation

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions