File: types.py

package info (click to toggle)
python-advanced-alchemy 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,708 kB
  • sloc: python: 25,811; makefile: 162; javascript: 123; sh: 4
file content (26 lines) | stat: -rw-r--r-- 829 bytes parent folder | download
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
"""Type aliases and constants used in the package config."""

from collections.abc import Mapping, Sequence
from typing import Any, Callable, Literal

from typing_extensions import TypeAlias

TypeEncodersMap: TypeAlias = Mapping[Any, Callable[[Any], Any]]
"""Type alias for a mapping of type encoders.

Maps types to their encoder functions.
"""

TypeDecodersSequence: TypeAlias = Sequence[tuple[Callable[[Any], bool], Callable[[Any, Any], Any]]]
"""Type alias for a sequence of type decoders.

Each tuple contains a type check predicate and its corresponding decoder function.
"""

CommitStrategy: TypeAlias = Literal["always", "match_status"]
"""Commit strategy for SQLAlchemy sessions.

Values:
    always: Always commit the session after operations
    match_status: Only commit if the HTTP status code indicates success
"""