python: Annotate type aliases with TypeAlias.

This is not strictly necessary but it’s clearer and improves mypy’s
error messages.

https://docs.python.org/3/library/typing.html#typing.TypeAlias
https://mypy.readthedocs.io/en/stable/kinds_of_types.html#type-aliases

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2023-08-02 14:53:10 -07:00
committed by Tim Abbott
parent f55711dae3
commit c2c96eb0cf
24 changed files with 81 additions and 52 deletions

View File

@@ -3,10 +3,11 @@ from typing import Any, Callable, Dict, Iterable, List, Mapping, Sequence, TypeV
from psycopg2.extensions import connection, cursor
from psycopg2.sql import Composable
from typing_extensions import TypeAlias
CursorObj = TypeVar("CursorObj", bound=cursor)
Query = Union[str, bytes, Composable]
Params = Union[Sequence[object], Mapping[str, object], None]
Query: TypeAlias = Union[str, bytes, Composable]
Params: TypeAlias = Union[Sequence[object], Mapping[str, object], None]
ParamsT = TypeVar("ParamsT")