mirror of
https://github.com/microsoft/pyright.git
synced 2024-11-14 16:20:11 +03:00
Fixed bug in dataclass logic that reported spurious error when initializing attribute with field(init=False)
.
This commit is contained in:
parent
077139fe66
commit
33acf3cb88
@ -1776,6 +1776,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
|
||||
(p) => p.hasDefault && p.includeInInit
|
||||
);
|
||||
if (
|
||||
includeInInit &&
|
||||
!hasDefaultValue &&
|
||||
firstDefaultValueIndex >= 0 &&
|
||||
firstDefaultValueIndex < insertIndex
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user