Description
Bug Report
Consider the following class definition:
from dataclasses import dataclass, InitVar
@dataclass
class MyClass:
prop: InitVar[int]
_prop: int
def __post_init__(self, prop: int):
self._prop = prop
@property
def prop(self) -> int:
return self._prop
Mypy reports an error on line 10: Name "prop" already defined on line 4
.
Is this a false positive? If not, how can I avoid this short of renaming the "prop
" attribute or getter method (or using #typing: ignore
)?
Environment
- Mypy version used: 0.931
- Python version used: 3.10.1
- Operating system and version: Windows 10 x64