You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is incorrect; since the class has a __dict__ in it's __slots__, it has a dict to put other in. This is described in https://docs.python.org/3/reference/datamodel.html#slots (both __dict__ and __weakref__ can be declared in __slots__), and is an important technique for wrapper classes, where the wrapped object is declared in slots, so that the __dict__ has everything except the wrapped object.
Basically. The condition is actually if a class has a __dict__, not if it has __slots__. Classes without __slots__ (anywhere in the inheritance chain) automatically get a __dict__. Classes with __slots__ (including in every parent) only get a dict if it's added manually in __slots__.
I assume you couldn't handle complex cases, but in the most common simple case of of a __slots__ having a string "__dict__", I assume you could treat that like a dict class?
Currently, PLE0237 will report "Attribute
other
is not defined in class's__slots__
" on a class like this:Which is correct. But it also reports the same error on the following correct class:
This is incorrect; since the class has a
__dict__
in it's__slots__
, it has a dict to putother
in. This is described in https://docs.python.org/3/reference/datamodel.html#slots (both__dict__
and__weakref__
can be declared in__slots__
), and is an important technique for wrapper classes, where the wrapped object is declared in slots, so that the__dict__
has everything except the wrapped object.Incorrect check result seen in scikit-hep/boost-histogram#914.
ruff check --select=ALL --isolated tmp.py
The text was updated successfully, but these errors were encountered: