Useful lesser known Python types

Final

from typing import Final

_PI: Final[float] = 3.14

Hashable

from typing import Any, Dict
from collections.abc import Hashable

my_dict: Dict[Hashable, Any]

TypedDict

# Python >= 3.11
from typing import Optional, NotRequired, TypedDict

# Python < 3.11
from typing import Optional
from typing_extensions import NotRequired, TypedDict

class MyTypedDict(TypedDict):
    my_key1: Optional[int]     # int | None
    my_key2: NotRequired[int]  # can be omitted

my_typed_dict: MyTypedDict