File: recursive.py

package info (click to toggle)
python-apischema 0.18.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,608 kB
  • sloc: python: 15,266; sh: 7; makefile: 7
file content (13 lines) | stat: -rw-r--r-- 256 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
from dataclasses import dataclass
from typing import Optional

from apischema import deserialize


@dataclass
class Node:
    value: int
    child: Optional["Node"] = None


assert deserialize(Node, {"value": 0, "child": {"value": 1}}) == Node(0, Node(1))