slay.py

1from typing import NamedTuple, Literal, Annotated
2
3class ServerMessage(NamedTuple):
4    type: Annotated[Literal["success", "error"], str]
5    duration: int
6    content: str
class ServerMessage(typing.NamedTuple):
4class ServerMessage(NamedTuple):
5    type: Annotated[Literal["success", "error"], str]
6    duration: int
7    content: str

ServerMessage(type, duration, content)

ServerMessage( type: Annotated[Literal['success', 'error'], <class 'str'>], duration: int, content: str)

Create new instance of ServerMessage(type, duration, content)

type: Annotated[Literal['success', 'error'], <class 'str'>]

Alias for field number 0

duration: int

Alias for field number 1

content: str

Alias for field number 2