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
« 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
4from pydantic import BaseModel, Field
6_ResponseT = TypeVar('_ResponseT', bound=Union[BaseModel, dict])
7"""Dynamic response type."""
9T = TypeVar('T')
12class UnsetType:
13 """Sentinel type to indicate an unset field value."""
15 _instance = None
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
22 def __repr__(self):
23 return '<UNSET>'
25 def __str__(self):
26 return 'UNSET'
28 def __bool__(self):
29 return False
32UNSET = UnsetType()
34Unset = Union[T, Literal[UNSET]] # type: ignore[valid-type]
35""" Optional argument tipi """
37UnsetOrNone = Union[T, Literal[UNSET], None] # type: ignore[valid-type]
38"""None dəyəri ala bilən optional argument tipi"""
40UnsetField = Annotated[Unset[T], Field(default=UNSET, exclude_if=lambda x: x is UNSET)]
41"""Pydantic üçün set olunmamış argument dəyəri"""
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"""
47class Environment(str, Enum):
48 TEST = 'test'
49 PROD = 'prod'