Coverage for sqlmodel/default.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-27 00:03 +0000

1from typing import Any, TypeVar 1abcdefghij

2 

3 

4class _DefaultPlaceholder: 1abcdefghij

5 """ 

6 You shouldn't use this class directly. 

7 

8 It's used internally to recognize when a default value has been overwritten, even 

9 if the overridden default value was truthy. 

10 """ 

11 

12 def __init__(self, value: Any): 1abcdefghij

13 self.value = value 1klmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX

14 

15 def __bool__(self) -> bool: 1abcdefghij

16 return bool(self.value) 1koswAEIMQU

17 

18 def __eq__(self, o: object) -> bool: 1abcdefghij

19 return isinstance(o, _DefaultPlaceholder) and o.value == self.value 1lmnpqrtuvxyzBCDFGHJKLNOPRSTVWX

20 

21 

22_TDefaultType = TypeVar("_TDefaultType") 1abcdefghij

23 

24 

25def Default(value: _TDefaultType) -> _TDefaultType: 1abcdefghij

26 """ 

27 You shouldn't use this function directly. 

28 

29 It's used internally to recognize when a default value has been overwritten, even 

30 if the overridden default value was truthy. 

31 """ 

32 return _DefaultPlaceholder(value) # type: ignore 1klmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX