Coverage for src/prisma/bases.py: 97%

57 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2024-08-27 18:25 +0000

1# -*- coding: utf-8 -*- 

2# code generated by Prisma. DO NOT EDIT. 

3# pyright: reportUnusedImport=false 

4# fmt: off 

5 

6# global imports for type checking 

7from builtins import bool as _bool 

8from builtins import int as _int 

9from builtins import float as _float 

10from builtins import str as _str 

11import sys 

12import decimal 

13import datetime 

14from typing import ( 

15 TYPE_CHECKING, 

16 Optional, 

17 Iterable, 

18 Iterator, 

19 Sequence, 

20 Callable, 

21 ClassVar, 

22 NoReturn, 

23 TypeVar, 

24 Generic, 

25 Mapping, 

26 Tuple, 

27 Union, 

28 List, 

29 Dict, 

30 Type, 

31 Any, 

32 Set, 

33 overload, 

34 cast, 

35) 

36from typing_extensions import TypedDict, Literal 

37 

38 

39LiteralString = str 

40# -- template models.py.jinja -- 

41from pydantic import BaseModel 

42 

43from . import fields, actions 

44from ._types import FuncType 

45from ._builder import serialize_base64 

46from ._compat import PYDANTIC_V2, ConfigDict 

47 

48if TYPE_CHECKING: 

49 from .client import Prisma 

50 

51 

52_PrismaModelT = TypeVar('_PrismaModelT', bound='_PrismaModel') 

53 

54 

55class _PrismaModel(BaseModel): 

56 if PYDANTIC_V2: 

57 model_config: ClassVar[ConfigDict] = ConfigDict( 

58 use_enum_values=True, 

59 arbitrary_types_allowed=True, 

60 populate_by_name=True, 

61 ) 

62 elif not TYPE_CHECKING: 

63 from ._compat import BaseConfig 

64 

65 class Config(BaseConfig): 

66 use_enum_values: bool = True 

67 arbitrary_types_allowed: bool = True 

68 allow_population_by_field_name: bool = True 

69 json_encoders: Dict[Any, FuncType] = { 

70 fields.Base64: serialize_base64, 

71 } 

72 

73 # TODO: ensure this is required by subclasses 

74 __prisma_model__: ClassVar[str] 

75 

76 

77class BasePost(_PrismaModel): 

78 __prisma_model__: ClassVar[Literal['Post']] = 'Post' # pyright: ignore[reportIncompatibleVariableOverride] 

79 

80 @classmethod 

81 def prisma(cls: Type[_PrismaModelT], client: Optional['Prisma'] = None) -> 'actions.PostActions[_PrismaModelT]': 

82 from .client import get_client 

83 

84 return actions.PostActions[_PrismaModelT](client or get_client(), cls) 

85 

86 

87class BaseUser(_PrismaModel): 

88 __prisma_model__: ClassVar[Literal['User']] = 'User' # pyright: ignore[reportIncompatibleVariableOverride] 

89 

90 @classmethod 

91 def prisma(cls: Type[_PrismaModelT], client: Optional['Prisma'] = None) -> 'actions.UserActions[_PrismaModelT]': 

92 from .client import get_client 

93 

94 return actions.UserActions[_PrismaModelT](client or get_client(), cls) 

95 

96 

97class BaseCategory(_PrismaModel): 

98 __prisma_model__: ClassVar[Literal['Category']] = 'Category' # pyright: ignore[reportIncompatibleVariableOverride] 

99 

100 @classmethod 

101 def prisma(cls: Type[_PrismaModelT], client: Optional['Prisma'] = None) -> 'actions.CategoryActions[_PrismaModelT]': 

102 from .client import get_client 

103 

104 return actions.CategoryActions[_PrismaModelT](client or get_client(), cls) 

105 

106 

107class BaseProfile(_PrismaModel): 

108 __prisma_model__: ClassVar[Literal['Profile']] = 'Profile' # pyright: ignore[reportIncompatibleVariableOverride] 

109 

110 @classmethod 

111 def prisma(cls: Type[_PrismaModelT], client: Optional['Prisma'] = None) -> 'actions.ProfileActions[_PrismaModelT]': 

112 from .client import get_client 

113 

114 return actions.ProfileActions[_PrismaModelT](client or get_client(), cls) 

115 

116 

117class BaseTypes(_PrismaModel): 

118 __prisma_model__: ClassVar[Literal['Types']] = 'Types' # pyright: ignore[reportIncompatibleVariableOverride] 

119 

120 @classmethod 

121 def prisma(cls: Type[_PrismaModelT], client: Optional['Prisma'] = None) -> 'actions.TypesActions[_PrismaModelT]': 

122 from .client import get_client 

123 

124 return actions.TypesActions[_PrismaModelT](client or get_client(), cls) 

125 

126