Skip to content

Spurious error for dataclass(slots=True) #17121

Open
@hauntsaninja

Description

@hauntsaninja

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 :-)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions