NO.Idea

Type Hints

NamedTuple vs namedtuple#

use from typing import NamedTuple instead of from collections import namedtuple.

Nullable#

When a variable could be None, there are two notations for this.

  • Union[str, None]
  • Optional[str]

Class Itself#

If using python 3.6 or lower version, Use string 'Node'.

Type Checking#

  • Pyright
  • Mypy
    • Mypy works better as it can check attribute type in a class without standard constructor, such as dataclass or attr.
  • Reconciling Dataclasses And Properties In Python