-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtyping.py
More file actions
38 lines (26 loc) · 964 Bytes
/
typing.py
File metadata and controls
38 lines (26 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Common type-hints for tcod.ecs."""
from __future__ import annotations
from types import EllipsisType
from typing import TYPE_CHECKING, Any, TypeAlias, TypeVar
from typing_extensions import TypeForm
if TYPE_CHECKING:
from tcod.ecs.entity import Entity
from tcod.ecs.query import BoundQuery
else:
Entity = Any
BoundQuery = Any
_T = TypeVar("_T")
ComponentKey: TypeAlias = TypeForm[_T] | tuple[object, TypeForm[_T]]
"""ComponentKey is plain `type` or tuple `(tag, type)`."""
_RelationTargetLookup: TypeAlias = Entity | EllipsisType
"""Possible target for stored relations."""
_RelationQueryTarget: TypeAlias = _RelationTargetLookup | BoundQuery
"""Possible target for relation queries."""
_RelationQuery: TypeAlias = tuple[object, _RelationQueryTarget] | tuple[_RelationQueryTarget, object, None] # noqa: PYI047
"""Query format for relations.
One of 4 formats:
* (tag, target)
* (tag, ...)
* (origin, tag, None)
* (..., tag, None)
"""