Skip to content

Spurious error for dataclass(slots=True) #17121

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

Open
hauntsaninja opened this issue Apr 13, 2024 · 0 comments
Open

Spurious error for dataclass(slots=True) #17121

hauntsaninja opened this issue Apr 13, 2024 · 0 comments
Assignees
Labels
bug mypy got something wrong topic-dataclasses

Comments

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Apr 13, 2024

I get a spurious top/fid/yod.py:6: error: "File" both defines "__slots__" and is used with "slots=True" [misc].

Similar to #11821 / #11827, but a more involved repro. I found it not trivial to minimise the repro beyond the following script:

rm -rf top

mkdir top
echo 'from . import fid' > top/__init__.py

mkdir top/fid
echo 'from .dug import X
from .fun import *
from .yod import File' > top/fid/__init__.py

echo 'from dataclasses import dataclass
import top.fid.fun as T
@dataclass
class X(T.MB): ...' > top/fid/dug.py

echo 'from dataclasses import dataclass
from top import does_not_exist  # type: ignore
@dataclass
class MB:
    ...' > top/fid/fun.py

echo 'from dataclasses import dataclass
import top
@dataclass(slots=True)
class File:
    path: str' > top/fid/yod.py

mypy top

cc @sobolevn in case you're interested, since you fixed the previous report :-)

@hauntsaninja hauntsaninja added the bug mypy got something wrong label Apr 13, 2024
@sobolevn sobolevn self-assigned this Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-dataclasses
Projects
None yet
Development

No branches or pull requests

3 participants