-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
Description
Bug Report
This code sample gives errors on the presence of f
in X
's constructor but not on DX
's
from __future__ import annotations
from typing import Callable, Type
from dataclasses import dataclass
def clsdec(x: Callable[[int, str, object], object]) -> Type:
return x # type: ignore
@clsdec
class X(object):
def __init__(self, x: int, y: str, z: object, f: float) -> None:
pass
@clsdec
@dataclass
class DX(object):
x: int
y: str
z: object
f: float
It seems like it can't "see" the dataclass's fields somehow, despite otherwise reporting sensible errors at the call site.
In fact, clsdec(DX)
gives the same error; it's only a problem when it's used in the decorator position.
Your Environment
- Mypy version used: mypy 0.961 (compiled: yes)
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: Python 3.10.4 (python.org)
- Operating system and version:
ProductName: macOS
ProductVersion: 12.4
BuildVersion: 21F79