Coverage for muutils / json_serialize / types.py: 0%

16 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-02-18 02:51 -0700

1"""base types, lets us avoid import cycles""" 

2 

3from __future__ import annotations 

4 

5from typing import TYPE_CHECKING, List, Literal, Union, Tuple 

6 

7if TYPE_CHECKING: 

8 from muutils.json_serialize.util import JSONitem 

9 

10 

11BaseType = Union[ 

12 bool, 

13 int, 

14 float, 

15 str, 

16 None, 

17] 

18 

19Hashableitem = Union[BaseType, Tuple["Hashableitem", ...]] 

20 

21 

22_FORMAT_KEY: Literal["__muutils_format__"] = "__muutils_format__" 

23_REF_KEY: Literal["$ref"] = "$ref" 

24 

25 

26# TypedDicts for serialized set/frozenset - using Total=False workaround for 3.8 compat 

27# These are used by @overload signatures for better type narrowing 

28try: 

29 from typing import TypedDict 

30except ImportError: 

31 from typing_extensions import TypedDict 

32 

33 

34class _SerializedSet(TypedDict): 

35 """TypedDict for serialized set objects.""" 

36 

37 __muutils_format__: Literal["set"] 

38 data: List["JSONitem"] 

39 

40 

41class _SerializedFrozenset(TypedDict): 

42 """TypedDict for serialized frozenset objects.""" 

43 

44 __muutils_format__: Literal["frozenset"] 

45 data: List["JSONitem"]