Since mypy now supports __slots__ checking, we can add __slots__ to stubs.
This will allow us to correctly raise Something is not in __slots__ when assigning extra attributes.
Right now there are no __slots__ defined: https://github.com/python/typeshed/search?q=__slots__
If this is something we are going for, there are several things to consider:
-
Adding this feature to stubtest. It can check that __slots__ contents do match. Probably behind a feature flag. We can enable it for stdlib only
-
Should we allow skipping _protected attributes? For example, if some class is defined as
class A:
__slots__ = ('_prop',)
Should we allow this stub?