1 # SPDX-License-Identifier: GPL-3.0-or-later
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2024 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Type definitions for typing annotations.
10 Complex type definitions are moved here, to keep the source files readable.
12 from typing import Union, TYPE_CHECKING
14 # pylint: disable=missing-class-docstring,useless-import-alias
16 # SQLAlchemy introduced generic types in version 2.0 making typing
17 # incompatible with older versions. Add wrappers here so we don't have
18 # to litter the code with bare-string types.
21 from typing import Any
22 import sqlalchemy as sa
24 from typing_extensions import (TypeAlias as TypeAlias)
28 StrPath = Union[str, 'os.PathLike[str]']
30 SaLambdaSelect: TypeAlias = 'Union[sa.Select[Any], sa.StatementLambdaElement]'
31 SaSelect: TypeAlias = 'sa.Select[Any]'
32 SaScalarSelect: TypeAlias = 'sa.ScalarSelect[Any]'
33 SaRow: TypeAlias = 'sa.Row[Any]'
34 SaColumn: TypeAlias = 'sa.ColumnElement[Any]'
35 SaExpression: TypeAlias = 'sa.ColumnElement[bool]'
36 SaLabel: TypeAlias = 'sa.Label[Any]'
37 SaFromClause: TypeAlias = 'sa.FromClause'
38 SaSelectable: TypeAlias = 'sa.Selectable'
39 SaBind: TypeAlias = 'sa.BindParameter[Any]'
40 SaDialect: TypeAlias = 'sa.Dialect'