Skip to content

Invalid instance.__slots__ type revealed #11891

Closed
@sobolevn

Description

@sobolevn

Here's a minimal repro:

class Bar(object):
    ...

reveal_type(Bar.__slots__)
reveal_type(Bar().__slots__)

Output:

out/ex.py:6: note: Revealed type is "typing.Iterable[builtins.str]"
out/ex.py:7: note: Revealed type is "typing.Iterable[builtins.str]"

What happens in runtime?

>>> class Bar(object):
...     ...
... 
>>> Bar.__slots__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'Bar' has no attribute '__slots__'. Did you mean: '__class__'?
>>> Bar().__slots__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Bar' object has no attribute '__slots__'. Did you mean: '__class__'?

__slots__ are special.

Related #11885

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions