Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 584 Bytes

postponed-evaluation-of-type-annotation.md

File metadata and controls

22 lines (17 loc) · 584 Bytes

Postponed evaluation of type annotation

PEP563 Postponed evaluation of type annotation is supported.

from __future__ import annotations
from serde import serde
from dataclasses import dataclass

@serde
@dataclass
class Foo:
    i: int
    s: str
    f: float
    b: bool

    def foo(self, cls: Foo):  # You can use "Foo" type before it's defined.
        print('foo')

For complete example, please see examples/lazy_type_evaluation.py