Python type hints - typing.Literal

Python tip:

You can use Literal to indicate that value can be one of the provided literals.

Static type checkers will report an error when the value doesn't match one of the provided literals.

from typing import Literal


class User:
    def __init__(self, username: str, status: STATUS):
        self.username = username
        self.status = status

user = User("[email protected]", "CREATED")

mypy error: Argument 2 to "User" has incompatible type "Literal['CREATED']";
expected "Union[Literal['ACTIVE'], Literal['DISABLED']]"
Found 1 error in 1 file (checked 1 source file)