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

8 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-04-04 03:33 -0600

1from __future__ import annotations 

2 

3import typing 

4from typing import Any, Union 

5 

6 

7def dataclass_transform( 

8 *, 

9 eq_default: bool = True, 

10 order_default: bool = False, 

11 kw_only_default: bool = False, 

12 frozen_default: bool = False, 

13 field_specifiers: tuple[Union[type[Any], typing.Callable[..., Any]], ...] = (), 

14 **kwargs: Any, 

15) -> typing.Callable: 

16 "mock `typing.dataclass_transform` for python <3.11" 

17 

18 def decorator(cls_or_fn): 

19 cls_or_fn.__dataclass_transform__ = { 

20 "eq_default": eq_default, 

21 "order_default": order_default, 

22 "kw_only_default": kw_only_default, 

23 "frozen_default": frozen_default, 

24 "field_specifiers": field_specifiers, 

25 "kwargs": kwargs, 

26 } 

27 return cls_or_fn 

28 

29 return decorator