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?
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 forstdlibonlyShould we allow skipping
_protectedattributes? For example, if some class is defined asShould we allow this stub?