Closed
Description
From python/typeshed#132 (comment) (@gvanrossum):
I think this may be undocumented but it's not meant to be varying by Python implementation -- the rule is that classes defined in extension modules don't have
__dict__
but anything defined using a class statement has a__dict__
unless it defines__slots__
and all its base classes also don't have a__dict__
.Hm, that actually suggests a way to mark classes that doesn't require anything new in typing.py: we could add
__slots__
to all classes that are supposed to be builtin (e.g. object, str, int) and mypy could implement a new rule that implicitly adds__dict__
:Dict[str, Any]
to any class definition that doesn't have__slots__
.