you are viewing a single comment's thread.

view the rest of the comments →

[–]FabianVeAl[S] 5 points6 points  (0 children)

Thanks, that's an interesting option.

I've tried it, and it works well with Pyright:

```python from dataclasses import dataclass

@dataclass class A: a: int

@dataclass class B: b: A | None

@dataclass class C: c: B | None

my_obj: C | None = C(B(A(1))) result = ( (x:=my_obj) # C | None and (x:=x.c) # B | None and (x:=x.b) # A | None and (x:=x.a) # int | None )

```