Open
Description
When the first argument of setattr
is of type NoneType
or EllipsisType
the function will always raise an AttributeError
on runtime, so it would be nice if the following calls would be detected as type errors.
x = None
setattr(x, 'foo', True) # AttributeError: 'NoneType' object has no attribute 'test'
y = ...
setattr(y, 'foo', True) # AttributeError: 'ellipsis' object has no attribute 'test'
I am not sure what's the best way to go about this is, there are probably many builtin types that do not support arbitrary attributes to be set. We do not appear to have a type to categorize such types, which could then in the future be used with Not[]
, once python/typing#801 is implemented.