Add common types for natively Json objects

master
Felix Stupp 9 months ago
parent e49789ede1
commit f311c53c9f
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -20,9 +20,23 @@ from ._string import (
from ._subprocess import (
call,
)
from ._types import (
JsonContainer,
JsonLeaf,
JsonList,
JsonMapping,
JsonMappingKey,
JsonRepr,
)
__all__ = [
"JsonContainer",
"JsonLeaf",
"JsonList",
"JsonMapping",
"JsonMappingKey",
"JsonRepr",
"all_same",
"call",
"date_to_datetime",

@ -0,0 +1,25 @@
from __future__ import annotations
from collections.abc import (
Sequence,
Mapping,
)
from typing import (
TypeAlias,
)
JsonMappingKey: TypeAlias = str | int | float
"""type for use in JSON mappings as key"""
JsonLeaf: TypeAlias = JsonMappingKey | bool | None
"""object natively mapping to JSON as values excluding containers"""
JsonMapping: TypeAlias = Mapping[JsonMappingKey, "JsonRepr"]
"""mapping natively mapping to JSON"""
JsonList: TypeAlias = Sequence["JsonRepr"]
"""list natively mapping to JSON"""
JsonContainer: TypeAlias = JsonList | JsonMapping
"""container natively mapping to JSON"""
JsonRepr: TypeAlias = JsonContainer | JsonLeaf
"""object natively mapping to JSON"""
Loading…
Cancel
Save