Coverage for src/integrify/utils.py: 88%

23 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2026-01-19 02:27 +0000

1from enum import Enum 

2from typing import Annotated, Literal, TypeVar, Union 

3 

4from pydantic import BaseModel, Field 

5 

6_ResponseT = TypeVar('_ResponseT', bound=Union[BaseModel, dict]) 

7"""Dynamic response type.""" 

8 

9T = TypeVar('T') 

10 

11 

12class UnsetType: 

13 """Sentinel type to indicate an unset field value.""" 

14 

15 _instance = None 

16 

17 def __new__(cls): 

18 if cls._instance is None: 18 ↛ 20line 18 didn't jump to line 20 because the condition on line 18 was always true

19 cls._instance = super().__new__(cls) 

20 return cls._instance 

21 

22 def __repr__(self): 

23 return '<UNSET>' 

24 

25 def __str__(self): 

26 return 'UNSET' 

27 

28 def __bool__(self): 

29 return False 

30 

31 

32UNSET = UnsetType() 

33 

34Unset = Union[T, Literal[UNSET]] # type: ignore[valid-type] 

35""" Optional argument tipi """ 

36 

37UnsetOrNone = Union[T, Literal[UNSET], None] # type: ignore[valid-type] 

38"""None dəyəri ala bilən optional argument tipi""" 

39 

40UnsetField = Annotated[Unset[T], Field(default=UNSET, exclude_if=lambda x: x is UNSET)] 

41"""Pydantic üçün set olunmamış argument dəyəri""" 

42 

43UnsetOrNoneField = Annotated[UnsetOrNone[T], Field(default=UNSET, exclude_if=lambda x: x is UNSET)] 

44"""Pydantic üçün set olunmamış və None dəyəri ala bilən argument dəyəri""" 

45 

46 

47class Environment(str, Enum): 

48 TEST = 'test' 

49 PROD = 'prod'