Skip to content
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

False error for dataclass slots when class is referenced earlier #11827

Closed
wrobell opened this issue Dec 22, 2021 · 1 comment · Fixed by #11824
Closed

False error for dataclass slots when class is referenced earlier #11827

wrobell opened this issue Dec 22, 2021 · 1 comment · Fixed by #11824
Labels
bug mypy got something wrong

Comments

@wrobell
Copy link

wrobell commented Dec 22, 2021

Please consider

import dataclasses as dtc
import asyncio

PublishedMessagesVar = dict[int, 'PublishedMessages']

@dtc.dataclass(frozen=True, slots=True)
class PublishedMessages:
    task: asyncio.Future[int]
    left: int
    right: int

then

$ mypy t2.py
t2.py:7: error: "PublishedMessages" both defines "__slots__" and is used with "slots=True"
Found 1 error in 1 file (checked 1 source file)

Above with Mypy 0.930, Python 3.10.1

There is no problem

  • when line with PublishedMessagesVar is removed
  • with Mypy 0.921
@wrobell wrobell added the bug mypy got something wrong label Dec 22, 2021
@wrobell wrobell changed the title False error for dataclass slots when class is references earlier False error for dataclass slots when class is referenced earlier Dec 23, 2021
@sobolevn
Copy link
Member

Looks like a duplicate of #11821

I will provide a test case for this as well.
See #11824

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants