Closed
Description
Describe the bug
Final variables are required to be initialized. If they aren't class variables they are expected to be initialized in constructor. The automatically generated dataclass constructor is not being counted as having assigned that variable.
To Reproduce
from dataclasses import dataclass
from typing import Final
class Foo1:
x: Final[int]
def __init__(self, x: int) -> None:
self.x = x
@dataclass
class Foo2:
x: Final[int] # Error: "x" is declared as "Final[int]", but value is not assigned.
Expected behavior
I would expect no errors similar to Foo1.
VS Code extension or command-line
pyright 1.1.212
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment