Skip to content

Protocol requires __slots__ to be explicitly typed #7290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matthewvalentine opened this issue Aug 5, 2019 · 1 comment · Fixed by #9314
Closed

Protocol requires __slots__ to be explicitly typed #7290

matthewvalentine opened this issue Aug 5, 2019 · 1 comment · Fixed by #9314
Labels

Comments

@matthewvalentine
Copy link

Bug report. Mypy version: mypy 0.730+dev.445020f0ed9939b43371edbddcf5b083a706d6d8

Code:

class A(Protocol):
    __slots__ = ()

Expected:

Passes, and __slots__ is not part of the Protocol interface. It's just being provided to prevent subclasses from being forced to have a __dict__.

Actual:

error: All protocol members must have explicitly declared types
@msullivan msullivan added bug mypy got something wrong priority-2-low labels Aug 6, 2019
@msullivan
Copy link
Collaborator

This is a definitely a bug, though should be easy to work around with a type: ignore. It should be pretty easy to fix if you want to take a look

JukkaL pushed a commit that referenced this issue Aug 28, 2020
Closes #7290.

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants