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
« 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
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
39LiteralString = str
40# -- template models.py.jinja --
41from pydantic import BaseModel
43from . import fields, actions
44from ._types import FuncType
45from ._builder import serialize_base64
46from ._compat import PYDANTIC_V2, ConfigDict
48if TYPE_CHECKING:
49 from .client import Prisma
52_PrismaModelT = TypeVar('_PrismaModelT', bound='_PrismaModel')
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
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 }
73 # TODO: ensure this is required by subclasses
74 __prisma_model__: ClassVar[str]
77class BasePost(_PrismaModel):
78 __prisma_model__: ClassVar[Literal['Post']] = 'Post' # pyright: ignore[reportIncompatibleVariableOverride]
80 @classmethod
81 def prisma(cls: Type[_PrismaModelT], client: Optional['Prisma'] = None) -> 'actions.PostActions[_PrismaModelT]':
82 from .client import get_client
84 return actions.PostActions[_PrismaModelT](client or get_client(), cls)
87class BaseUser(_PrismaModel):
88 __prisma_model__: ClassVar[Literal['User']] = 'User' # pyright: ignore[reportIncompatibleVariableOverride]
90 @classmethod
91 def prisma(cls: Type[_PrismaModelT], client: Optional['Prisma'] = None) -> 'actions.UserActions[_PrismaModelT]':
92 from .client import get_client
94 return actions.UserActions[_PrismaModelT](client or get_client(), cls)
97class BaseCategory(_PrismaModel):
98 __prisma_model__: ClassVar[Literal['Category']] = 'Category' # pyright: ignore[reportIncompatibleVariableOverride]
100 @classmethod
101 def prisma(cls: Type[_PrismaModelT], client: Optional['Prisma'] = None) -> 'actions.CategoryActions[_PrismaModelT]':
102 from .client import get_client
104 return actions.CategoryActions[_PrismaModelT](client or get_client(), cls)
107class BaseProfile(_PrismaModel):
108 __prisma_model__: ClassVar[Literal['Profile']] = 'Profile' # pyright: ignore[reportIncompatibleVariableOverride]
110 @classmethod
111 def prisma(cls: Type[_PrismaModelT], client: Optional['Prisma'] = None) -> 'actions.ProfileActions[_PrismaModelT]':
112 from .client import get_client
114 return actions.ProfileActions[_PrismaModelT](client or get_client(), cls)
117class BaseTypes(_PrismaModel):
118 __prisma_model__: ClassVar[Literal['Types']] = 'Types' # pyright: ignore[reportIncompatibleVariableOverride]
120 @classmethod
121 def prisma(cls: Type[_PrismaModelT], client: Optional['Prisma'] = None) -> 'actions.TypesActions[_PrismaModelT]':
122 from .client import get_client
124 return actions.TypesActions[_PrismaModelT](client or get_client(), cls)