annotations.py 1.2 KB

123456789101112131415161718192021222324252627282930
  1. from __future__ import annotations
  2. from typing import TYPE_CHECKING, Iterable, Optional, TypeVar, Union
  3. from collections.abc import Callable, Sequence
  4. from fontTools.misc.filesystem._base import FS
  5. from os import PathLike
  6. from xml.etree.ElementTree import Element as ElementTreeElement
  7. if TYPE_CHECKING:
  8. from fontTools.ufoLib import UFOFormatVersion
  9. from fontTools.ufoLib.glifLib import GLIFFormatVersion
  10. from lxml.etree import _Element as LxmlElement
  11. T = TypeVar("T") # Generic type
  12. K = TypeVar("K") # Generic dict key type
  13. V = TypeVar("V") # Generic dict value type
  14. GlyphNameToFileNameFunc = Optional[Callable[[str, set[str]], str]]
  15. ElementType = Union[ElementTreeElement, "LxmlElement"]
  16. FormatVersion = Union[int, tuple[int, int]]
  17. FormatVersions = Optional[Iterable[FormatVersion]]
  18. GLIFFormatVersionInput = Optional[Union[int, tuple[int, int], "GLIFFormatVersion"]]
  19. UFOFormatVersionInput = Optional[Union[int, tuple[int, int], "UFOFormatVersion"]]
  20. IntFloat = Union[int, float]
  21. KerningPair = tuple[str, str]
  22. KerningDict = dict[KerningPair, IntFloat]
  23. KerningGroups = dict[str, Sequence[str]]
  24. KerningNested = dict[str, dict[str, IntFloat]]
  25. PathStr = Union[str, PathLike[str]]
  26. PathOrFS = Union[PathStr, FS]