Summary
from dataclasses import dataclass
from typing import Final
@dataclass
class Test:
def __post_init__(self):
self.test_int: Final[int] = 0
Ty complains: "Cannot assign to final attribute test_int on type Self@__post_init__: Final attributes can only be assigned in the class body or __init__".
As __init__ is typically not used directly in dataclasses, and body is meant to hold dynamic data, I believe that __post_init__ is a legitimate place for Final attributes.
Version
0.0.28
Summary
Ty complains: "Cannot assign to final attribute
test_inton typeSelf@__post_init__:Finalattributes can only be assigned in the class body or__init__".As
__init__is typically not used directly in dataclasses, and body is meant to hold dynamic data, I believe that__post_init__is a legitimate place for Final attributes.Version
0.0.28