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
 
  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,
 
  30 StrPath = Union[str, 'os.PathLike[str]']
 
  32 SaLambdaSelect: TypeAlias = 'Union[sa.Select[Any], sa.StatementLambdaElement]'
 
  33 SaSelect: TypeAlias = 'sa.Select[Any]'
 
  34 SaScalarSelect: TypeAlias = 'sa.ScalarSelect[Any]'
 
  35 SaRow: TypeAlias = 'sa.Row[Any]'
 
  36 SaColumn: TypeAlias = 'sa.ColumnElement[Any]'
 
  37 SaExpression: TypeAlias = 'sa.ColumnElement[bool]'
 
  38 SaLabel: TypeAlias = 'sa.Label[Any]'
 
  39 SaFromClause: TypeAlias = 'sa.FromClause'
 
  40 SaSelectable: TypeAlias = 'sa.Selectable'
 
  41 SaBind: TypeAlias = 'sa.BindParameter[Any]'
 
  42 SaDialect: TypeAlias = 'sa.Dialect'