diff --git a/server/src/analyzer/typeEvaluator.ts b/server/src/analyzer/typeEvaluator.ts index c7586809a..f10ccc7c0 100644 --- a/server/src/analyzer/typeEvaluator.ts +++ b/server/src/analyzer/typeEvaluator.ts @@ -1776,6 +1776,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags: (p) => p.hasDefault && p.includeInInit ); if ( + includeInInit && !hasDefaultValue && firstDefaultValueIndex >= 0 && firstDefaultValueIndex < insertIndex diff --git a/server/src/tests/samples/dataclass10.py b/server/src/tests/samples/dataclass10.py index 0c7262150..cfe2208c1 100644 --- a/server/src/tests/samples/dataclass10.py +++ b/server/src/tests/samples/dataclass10.py @@ -31,3 +31,15 @@ test = Child(prop_2="test", prop_4="hi") assert test.prop_1 == "test" assert test.prop_2 == "test" + +@dataclass +class HandshakeMessage: + reset_reason_hex: str + reset_data_hex: str + device_id: str = field(default="") + reset_reason: str = field(init=False) + reset_data: str = field(init=False) + + def __post_init__(self): + reset_reason = "calculated value" + reset_data = "calculated value"