Support detecting invalid __slots__ access
Would it be possible to detect invalid slot access? For example:
class Foo:
__slots__ = ('a', 'b')
f = Foo()
f.a = 1
f.b = 2
f.c = 3 # Detect that this is not valid
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In [18], line 1
----> 1 f.c = 3
AttributeError: 'Foo' object has no attribute 'c'
From looking through the code it looks like any store attribute access creates a declaration whether it is allowed or not.