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

mypy complaining that class annotated with @dataclass(slots=True) has no attribute __slots__ #15647

Closed
matthewsia98 opened this issue Jul 12, 2023 · 0 comments · Fixed by #15649
Labels
bug mypy got something wrong topic-dataclasses

Comments

@matthewsia98
Copy link

Bug Report

mypy complaining that class annotated with @dataclass(slots=True) has no attribute __slots__

To Reproduce

from dataclasses import dataclass


class Point1:
    __slots__ = ('x', 'y')


@dataclass(slots=True)
class Point2:
    x: float
    y: float


print(Point1.__slots__)
print(Point2.__slots__)

Expected Behavior

No error should be produced

Actual Behavior

Running python test.py produces

('x', 'y')
('x', 'y')

Running mypy test.py produces

test.py:15: error: "type[Point2]" has no attribute "__slots__"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 1.4.1
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.11.1
@matthewsia98 matthewsia98 added the bug mypy got something wrong label Jul 12, 2023
sobolevn added a commit that referenced this issue Jul 12, 2023
This is similar to #15649 but for
`attrs` :)
Refs #15647
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

Successfully merging a pull request may close this issue.

2 participants