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 attr-defined error when dataclass property mirrors initvar #13110

Closed
joshuafishman opened this issue Jul 12, 2022 · 2 comments
Closed

False attr-defined error when dataclass property mirrors initvar #13110

joshuafishman opened this issue Jul 12, 2022 · 2 comments
Labels
bug mypy got something wrong topic-dataclasses

Comments

@joshuafishman
Copy link

joshuafishman commented Jul 12, 2022

Bug Report

#12046 describes one false positive in this case. However, any time the mirrored attribute is referenced also raises a false positive attribute error. Short of ignoring every reference to the offending attribute, I don't see a workaround.

To Reproduce

from dataclasses import dataclass, InitVar


@dataclass
class Baz:
    foo: InitVar[int]

    @property  # type: ignore
    def foo(self) -> int:
        return 0


print(Baz(0).foo)

Actual Behavior

error: "Baz" has no attribute "foo" [attr-defined]

Your Environment

  • Mypy version used: 0.910
  • Python version used: 3.9
  • Operating system and version: Ubuntu 20.04
@joshuafishman joshuafishman added the bug mypy got something wrong label Jul 12, 2022
@AlexWaygood
Copy link
Member

Duplicate of #12046

@AlexWaygood AlexWaygood marked this as a duplicate of #12046 Jul 12, 2022
@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Jul 12, 2022
@AlexWaygood
Copy link
Member

Duplicate of #12046

Please add your additional details to the existing bug report — it's the same bug being exhibited here, just a slightly different symptom.

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

2 participants