worqhat 3.5.0__py3-none-any.whl → 3.8.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. worqhat/__init__.py +3 -1
  2. worqhat/_base_client.py +12 -12
  3. worqhat/_client.py +21 -11
  4. worqhat/_compat.py +48 -48
  5. worqhat/_models.py +51 -45
  6. worqhat/_qs.py +7 -7
  7. worqhat/_types.py +53 -12
  8. worqhat/_utils/__init__.py +9 -2
  9. worqhat/_utils/_compat.py +45 -0
  10. worqhat/_utils/_datetime_parse.py +136 -0
  11. worqhat/_utils/_transform.py +13 -3
  12. worqhat/_utils/_typing.py +6 -1
  13. worqhat/_utils/_utils.py +4 -5
  14. worqhat/_version.py +1 -1
  15. worqhat/resources/__init__.py +14 -0
  16. worqhat/resources/client/__init__.py +33 -0
  17. worqhat/resources/client/client.py +102 -0
  18. worqhat/resources/client/storage.py +462 -0
  19. worqhat/resources/db/__init__.py +33 -0
  20. worqhat/resources/{db.py → db/db.py} +245 -32
  21. worqhat/resources/db/tables.py +389 -0
  22. worqhat/resources/flows.py +29 -23
  23. worqhat/resources/health.py +3 -3
  24. worqhat/types/__init__.py +2 -0
  25. worqhat/types/client/__init__.py +12 -0
  26. worqhat/types/client/storage_delete_file_by_id_response.py +18 -0
  27. worqhat/types/client/storage_retrieve_file_by_id_response.py +33 -0
  28. worqhat/types/client/storage_retrieve_file_by_path_params.py +12 -0
  29. worqhat/types/client/storage_retrieve_file_by_path_response.py +33 -0
  30. worqhat/types/client/storage_upload_file_params.py +17 -0
  31. worqhat/types/client/storage_upload_file_response.py +33 -0
  32. worqhat/types/db/__init__.py +10 -0
  33. worqhat/types/db/table_get_row_count_params.py +12 -0
  34. worqhat/types/db/table_get_row_count_response.py +15 -0
  35. worqhat/types/db/table_list_params.py +15 -0
  36. worqhat/types/db/table_list_response.py +26 -0
  37. worqhat/types/db/table_retrieve_schema_params.py +12 -0
  38. worqhat/types/db/table_retrieve_schema_response.py +29 -0
  39. worqhat/types/db_delete_records_params.py +6 -2
  40. worqhat/types/db_delete_records_response.py +2 -2
  41. worqhat/types/db_execute_batch_params.py +36 -0
  42. worqhat/types/db_execute_batch_response.py +27 -0
  43. worqhat/types/db_execute_query_params.py +8 -1
  44. worqhat/types/db_execute_query_response.py +2 -2
  45. worqhat/types/db_insert_record_params.py +6 -2
  46. worqhat/types/db_insert_record_response.py +2 -2
  47. worqhat/types/db_process_nl_query_params.py +8 -1
  48. worqhat/types/db_process_nl_query_response.py +2 -2
  49. worqhat/types/db_update_records_params.py +7 -3
  50. worqhat/types/db_update_records_response.py +2 -2
  51. worqhat/types/flow_trigger_with_payload_params.py +3 -2
  52. {worqhat-3.5.0.dist-info → worqhat-3.8.0.dist-info}/METADATA +2 -2
  53. worqhat-3.8.0.dist-info/RECORD +76 -0
  54. worqhat-3.5.0.dist-info/RECORD +0 -53
  55. {worqhat-3.5.0.dist-info → worqhat-3.8.0.dist-info}/WHEEL +0 -0
  56. {worqhat-3.5.0.dist-info → worqhat-3.8.0.dist-info}/licenses/LICENSE +0 -0
worqhat/__init__.py CHANGED
@@ -3,7 +3,7 @@
3
3
  import typing as _t
4
4
 
5
5
  from . import types
6
- from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes
6
+ from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given
7
7
  from ._utils import file_from_path
8
8
  from ._client import Client, Stream, Timeout, Worqhat, Transport, AsyncClient, AsyncStream, AsyncWorqhat, RequestOptions
9
9
  from ._models import BaseModel
@@ -38,7 +38,9 @@ __all__ = [
38
38
  "ProxiesTypes",
39
39
  "NotGiven",
40
40
  "NOT_GIVEN",
41
+ "not_given",
41
42
  "Omit",
43
+ "omit",
42
44
  "WorqhatError",
43
45
  "APIError",
44
46
  "APIStatusError",
worqhat/_base_client.py CHANGED
@@ -42,7 +42,6 @@ from . import _exceptions
42
42
  from ._qs import Querystring
43
43
  from ._files import to_httpx_files, async_to_httpx_files
44
44
  from ._types import (
45
- NOT_GIVEN,
46
45
  Body,
47
46
  Omit,
48
47
  Query,
@@ -57,9 +56,10 @@ from ._types import (
57
56
  RequestOptions,
58
57
  HttpxRequestFiles,
59
58
  ModelBuilderProtocol,
59
+ not_given,
60
60
  )
61
61
  from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping
62
- from ._compat import PYDANTIC_V2, model_copy, model_dump
62
+ from ._compat import PYDANTIC_V1, model_copy, model_dump
63
63
  from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type
64
64
  from ._response import (
65
65
  APIResponse,
@@ -145,9 +145,9 @@ class PageInfo:
145
145
  def __init__(
146
146
  self,
147
147
  *,
148
- url: URL | NotGiven = NOT_GIVEN,
149
- json: Body | NotGiven = NOT_GIVEN,
150
- params: Query | NotGiven = NOT_GIVEN,
148
+ url: URL | NotGiven = not_given,
149
+ json: Body | NotGiven = not_given,
150
+ params: Query | NotGiven = not_given,
151
151
  ) -> None:
152
152
  self.url = url
153
153
  self.json = json
@@ -232,7 +232,7 @@ class BaseSyncPage(BasePage[_T], Generic[_T]):
232
232
  model: Type[_T],
233
233
  options: FinalRequestOptions,
234
234
  ) -> None:
235
- if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
235
+ if (not PYDANTIC_V1) and getattr(self, "__pydantic_private__", None) is None:
236
236
  self.__pydantic_private__ = {}
237
237
 
238
238
  self._model = model
@@ -320,7 +320,7 @@ class BaseAsyncPage(BasePage[_T], Generic[_T]):
320
320
  client: AsyncAPIClient,
321
321
  options: FinalRequestOptions,
322
322
  ) -> None:
323
- if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
323
+ if (not PYDANTIC_V1) and getattr(self, "__pydantic_private__", None) is None:
324
324
  self.__pydantic_private__ = {}
325
325
 
326
326
  self._model = model
@@ -595,7 +595,7 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
595
595
  # we internally support defining a temporary header to override the
596
596
  # default `cast_to` type for use with `.with_raw_response` and `.with_streaming_response`
597
597
  # see _response.py for implementation details
598
- override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, NOT_GIVEN)
598
+ override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, not_given)
599
599
  if is_given(override_cast_to):
600
600
  options.headers = headers
601
601
  return cast(Type[ResponseT], override_cast_to)
@@ -825,7 +825,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
825
825
  version: str,
826
826
  base_url: str | URL,
827
827
  max_retries: int = DEFAULT_MAX_RETRIES,
828
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
828
+ timeout: float | Timeout | None | NotGiven = not_given,
829
829
  http_client: httpx.Client | None = None,
830
830
  custom_headers: Mapping[str, str] | None = None,
831
831
  custom_query: Mapping[str, object] | None = None,
@@ -1356,7 +1356,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1356
1356
  base_url: str | URL,
1357
1357
  _strict_response_validation: bool,
1358
1358
  max_retries: int = DEFAULT_MAX_RETRIES,
1359
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
1359
+ timeout: float | Timeout | None | NotGiven = not_given,
1360
1360
  http_client: httpx.AsyncClient | None = None,
1361
1361
  custom_headers: Mapping[str, str] | None = None,
1362
1362
  custom_query: Mapping[str, object] | None = None,
@@ -1818,8 +1818,8 @@ def make_request_options(
1818
1818
  extra_query: Query | None = None,
1819
1819
  extra_body: Body | None = None,
1820
1820
  idempotency_key: str | None = None,
1821
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1822
- post_parser: PostParser | NotGiven = NOT_GIVEN,
1821
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1822
+ post_parser: PostParser | NotGiven = not_given,
1823
1823
  ) -> RequestOptions:
1824
1824
  """Create a dict of type RequestOptions without keys of NotGiven values."""
1825
1825
  options: RequestOptions = {}
worqhat/_client.py CHANGED
@@ -3,7 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import os
6
- from typing import Any, Union, Mapping
6
+ from typing import Any, Mapping
7
7
  from typing_extensions import Self, override
8
8
 
9
9
  import httpx
@@ -11,7 +11,6 @@ import httpx
11
11
  from . import _exceptions
12
12
  from ._qs import Querystring
13
13
  from ._types import (
14
- NOT_GIVEN,
15
14
  Body,
16
15
  Omit,
17
16
  Query,
@@ -21,6 +20,7 @@ from ._types import (
21
20
  Transport,
22
21
  ProxiesTypes,
23
22
  RequestOptions,
23
+ not_given,
24
24
  )
25
25
  from ._utils import is_given, get_async_library
26
26
  from ._version import __version__
@@ -30,7 +30,7 @@ from ._response import (
30
30
  async_to_raw_response_wrapper,
31
31
  async_to_streamed_response_wrapper,
32
32
  )
33
- from .resources import db, flows, health
33
+ from .resources import flows, health
34
34
  from ._streaming import Stream as Stream, AsyncStream as AsyncStream
35
35
  from ._exceptions import WorqhatError, APIStatusError
36
36
  from ._base_client import (
@@ -39,6 +39,8 @@ from ._base_client import (
39
39
  AsyncAPIClient,
40
40
  make_request_options,
41
41
  )
42
+ from .resources.db import db
43
+ from .resources.client import client
42
44
  from .types.get_server_info_response import GetServerInfoResponse
43
45
 
44
46
  __all__ = ["Timeout", "Transport", "ProxiesTypes", "RequestOptions", "Worqhat", "AsyncWorqhat", "Client", "AsyncClient"]
@@ -48,6 +50,7 @@ class Worqhat(SyncAPIClient):
48
50
  db: db.DBResource
49
51
  health: health.HealthResource
50
52
  flows: flows.FlowsResource
53
+ client: client.ClientResource
51
54
  with_raw_response: WorqhatWithRawResponse
52
55
  with_streaming_response: WorqhatWithStreamedResponse
53
56
 
@@ -59,7 +62,7 @@ class Worqhat(SyncAPIClient):
59
62
  *,
60
63
  api_key: str | None = None,
61
64
  base_url: str | httpx.URL | None = None,
62
- timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
65
+ timeout: float | Timeout | None | NotGiven = not_given,
63
66
  max_retries: int = DEFAULT_MAX_RETRIES,
64
67
  default_headers: Mapping[str, str] | None = None,
65
68
  default_query: Mapping[str, object] | None = None,
@@ -108,6 +111,7 @@ class Worqhat(SyncAPIClient):
108
111
  self.db = db.DBResource(self)
109
112
  self.health = health.HealthResource(self)
110
113
  self.flows = flows.FlowsResource(self)
114
+ self.client = client.ClientResource(self)
111
115
  self.with_raw_response = WorqhatWithRawResponse(self)
112
116
  self.with_streaming_response = WorqhatWithStreamedResponse(self)
113
117
 
@@ -136,9 +140,9 @@ class Worqhat(SyncAPIClient):
136
140
  *,
137
141
  api_key: str | None = None,
138
142
  base_url: str | httpx.URL | None = None,
139
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
143
+ timeout: float | Timeout | None | NotGiven = not_given,
140
144
  http_client: httpx.Client | None = None,
141
- max_retries: int | NotGiven = NOT_GIVEN,
145
+ max_retries: int | NotGiven = not_given,
142
146
  default_headers: Mapping[str, str] | None = None,
143
147
  set_default_headers: Mapping[str, str] | None = None,
144
148
  default_query: Mapping[str, object] | None = None,
@@ -190,7 +194,7 @@ class Worqhat(SyncAPIClient):
190
194
  extra_headers: Headers | None = None,
191
195
  extra_query: Query | None = None,
192
196
  extra_body: Body | None = None,
193
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
197
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
194
198
  ) -> GetServerInfoResponse:
195
199
  """Get basic server information and status"""
196
200
  return self.get(
@@ -239,6 +243,7 @@ class AsyncWorqhat(AsyncAPIClient):
239
243
  db: db.AsyncDBResource
240
244
  health: health.AsyncHealthResource
241
245
  flows: flows.AsyncFlowsResource
246
+ client: client.AsyncClientResource
242
247
  with_raw_response: AsyncWorqhatWithRawResponse
243
248
  with_streaming_response: AsyncWorqhatWithStreamedResponse
244
249
 
@@ -250,7 +255,7 @@ class AsyncWorqhat(AsyncAPIClient):
250
255
  *,
251
256
  api_key: str | None = None,
252
257
  base_url: str | httpx.URL | None = None,
253
- timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
258
+ timeout: float | Timeout | None | NotGiven = not_given,
254
259
  max_retries: int = DEFAULT_MAX_RETRIES,
255
260
  default_headers: Mapping[str, str] | None = None,
256
261
  default_query: Mapping[str, object] | None = None,
@@ -299,6 +304,7 @@ class AsyncWorqhat(AsyncAPIClient):
299
304
  self.db = db.AsyncDBResource(self)
300
305
  self.health = health.AsyncHealthResource(self)
301
306
  self.flows = flows.AsyncFlowsResource(self)
307
+ self.client = client.AsyncClientResource(self)
302
308
  self.with_raw_response = AsyncWorqhatWithRawResponse(self)
303
309
  self.with_streaming_response = AsyncWorqhatWithStreamedResponse(self)
304
310
 
@@ -327,9 +333,9 @@ class AsyncWorqhat(AsyncAPIClient):
327
333
  *,
328
334
  api_key: str | None = None,
329
335
  base_url: str | httpx.URL | None = None,
330
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
336
+ timeout: float | Timeout | None | NotGiven = not_given,
331
337
  http_client: httpx.AsyncClient | None = None,
332
- max_retries: int | NotGiven = NOT_GIVEN,
338
+ max_retries: int | NotGiven = not_given,
333
339
  default_headers: Mapping[str, str] | None = None,
334
340
  set_default_headers: Mapping[str, str] | None = None,
335
341
  default_query: Mapping[str, object] | None = None,
@@ -381,7 +387,7 @@ class AsyncWorqhat(AsyncAPIClient):
381
387
  extra_headers: Headers | None = None,
382
388
  extra_query: Query | None = None,
383
389
  extra_body: Body | None = None,
384
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
390
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
385
391
  ) -> GetServerInfoResponse:
386
392
  """Get basic server information and status"""
387
393
  return await self.get(
@@ -431,6 +437,7 @@ class WorqhatWithRawResponse:
431
437
  self.db = db.DBResourceWithRawResponse(client.db)
432
438
  self.health = health.HealthResourceWithRawResponse(client.health)
433
439
  self.flows = flows.FlowsResourceWithRawResponse(client.flows)
440
+ self.client = client.ClientResourceWithRawResponse(client.client)
434
441
 
435
442
  self.get_server_info = to_raw_response_wrapper(
436
443
  client.get_server_info,
@@ -442,6 +449,7 @@ class AsyncWorqhatWithRawResponse:
442
449
  self.db = db.AsyncDBResourceWithRawResponse(client.db)
443
450
  self.health = health.AsyncHealthResourceWithRawResponse(client.health)
444
451
  self.flows = flows.AsyncFlowsResourceWithRawResponse(client.flows)
452
+ self.client = client.AsyncClientResourceWithRawResponse(client.client)
445
453
 
446
454
  self.get_server_info = async_to_raw_response_wrapper(
447
455
  client.get_server_info,
@@ -453,6 +461,7 @@ class WorqhatWithStreamedResponse:
453
461
  self.db = db.DBResourceWithStreamingResponse(client.db)
454
462
  self.health = health.HealthResourceWithStreamingResponse(client.health)
455
463
  self.flows = flows.FlowsResourceWithStreamingResponse(client.flows)
464
+ self.client = client.ClientResourceWithStreamingResponse(client.client)
456
465
 
457
466
  self.get_server_info = to_streamed_response_wrapper(
458
467
  client.get_server_info,
@@ -464,6 +473,7 @@ class AsyncWorqhatWithStreamedResponse:
464
473
  self.db = db.AsyncDBResourceWithStreamingResponse(client.db)
465
474
  self.health = health.AsyncHealthResourceWithStreamingResponse(client.health)
466
475
  self.flows = flows.AsyncFlowsResourceWithStreamingResponse(client.flows)
476
+ self.client = client.AsyncClientResourceWithStreamingResponse(client.client)
467
477
 
468
478
  self.get_server_info = async_to_streamed_response_wrapper(
469
479
  client.get_server_info,
worqhat/_compat.py CHANGED
@@ -12,14 +12,13 @@ from ._types import IncEx, StrBytesIntFloat
12
12
  _T = TypeVar("_T")
13
13
  _ModelT = TypeVar("_ModelT", bound=pydantic.BaseModel)
14
14
 
15
- # --------------- Pydantic v2 compatibility ---------------
15
+ # --------------- Pydantic v2, v3 compatibility ---------------
16
16
 
17
17
  # Pyright incorrectly reports some of our functions as overriding a method when they don't
18
18
  # pyright: reportIncompatibleMethodOverride=false
19
19
 
20
- PYDANTIC_V2 = pydantic.VERSION.startswith("2.")
20
+ PYDANTIC_V1 = pydantic.VERSION.startswith("1.")
21
21
 
22
- # v1 re-exports
23
22
  if TYPE_CHECKING:
24
23
 
25
24
  def parse_date(value: date | StrBytesIntFloat) -> date: # noqa: ARG001
@@ -44,90 +43,92 @@ if TYPE_CHECKING:
44
43
  ...
45
44
 
46
45
  else:
47
- if PYDANTIC_V2:
48
- from pydantic.v1.typing import (
46
+ # v1 re-exports
47
+ if PYDANTIC_V1:
48
+ from pydantic.typing import (
49
49
  get_args as get_args,
50
50
  is_union as is_union,
51
51
  get_origin as get_origin,
52
52
  is_typeddict as is_typeddict,
53
53
  is_literal_type as is_literal_type,
54
54
  )
55
- from pydantic.v1.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
55
+ from pydantic.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
56
56
  else:
57
- from pydantic.typing import (
57
+ from ._utils import (
58
58
  get_args as get_args,
59
59
  is_union as is_union,
60
60
  get_origin as get_origin,
61
+ parse_date as parse_date,
61
62
  is_typeddict as is_typeddict,
63
+ parse_datetime as parse_datetime,
62
64
  is_literal_type as is_literal_type,
63
65
  )
64
- from pydantic.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
65
66
 
66
67
 
67
68
  # refactored config
68
69
  if TYPE_CHECKING:
69
70
  from pydantic import ConfigDict as ConfigDict
70
71
  else:
71
- if PYDANTIC_V2:
72
- from pydantic import ConfigDict
73
- else:
72
+ if PYDANTIC_V1:
74
73
  # TODO: provide an error message here?
75
74
  ConfigDict = None
75
+ else:
76
+ from pydantic import ConfigDict as ConfigDict
76
77
 
77
78
 
78
79
  # renamed methods / properties
79
80
  def parse_obj(model: type[_ModelT], value: object) -> _ModelT:
80
- if PYDANTIC_V2:
81
- return model.model_validate(value)
82
- else:
81
+ if PYDANTIC_V1:
83
82
  return cast(_ModelT, model.parse_obj(value)) # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
83
+ else:
84
+ return model.model_validate(value)
84
85
 
85
86
 
86
87
  def field_is_required(field: FieldInfo) -> bool:
87
- if PYDANTIC_V2:
88
- return field.is_required()
89
- return field.required # type: ignore
88
+ if PYDANTIC_V1:
89
+ return field.required # type: ignore
90
+ return field.is_required()
90
91
 
91
92
 
92
93
  def field_get_default(field: FieldInfo) -> Any:
93
94
  value = field.get_default()
94
- if PYDANTIC_V2:
95
- from pydantic_core import PydanticUndefined
96
-
97
- if value == PydanticUndefined:
98
- return None
95
+ if PYDANTIC_V1:
99
96
  return value
97
+ from pydantic_core import PydanticUndefined
98
+
99
+ if value == PydanticUndefined:
100
+ return None
100
101
  return value
101
102
 
102
103
 
103
104
  def field_outer_type(field: FieldInfo) -> Any:
104
- if PYDANTIC_V2:
105
- return field.annotation
106
- return field.outer_type_ # type: ignore
105
+ if PYDANTIC_V1:
106
+ return field.outer_type_ # type: ignore
107
+ return field.annotation
107
108
 
108
109
 
109
110
  def get_model_config(model: type[pydantic.BaseModel]) -> Any:
110
- if PYDANTIC_V2:
111
- return model.model_config
112
- return model.__config__ # type: ignore
111
+ if PYDANTIC_V1:
112
+ return model.__config__ # type: ignore
113
+ return model.model_config
113
114
 
114
115
 
115
116
  def get_model_fields(model: type[pydantic.BaseModel]) -> dict[str, FieldInfo]:
116
- if PYDANTIC_V2:
117
- return model.model_fields
118
- return model.__fields__ # type: ignore
117
+ if PYDANTIC_V1:
118
+ return model.__fields__ # type: ignore
119
+ return model.model_fields
119
120
 
120
121
 
121
122
  def model_copy(model: _ModelT, *, deep: bool = False) -> _ModelT:
122
- if PYDANTIC_V2:
123
- return model.model_copy(deep=deep)
124
- return model.copy(deep=deep) # type: ignore
123
+ if PYDANTIC_V1:
124
+ return model.copy(deep=deep) # type: ignore
125
+ return model.model_copy(deep=deep)
125
126
 
126
127
 
127
128
  def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
128
- if PYDANTIC_V2:
129
- return model.model_dump_json(indent=indent)
130
- return model.json(indent=indent) # type: ignore
129
+ if PYDANTIC_V1:
130
+ return model.json(indent=indent) # type: ignore
131
+ return model.model_dump_json(indent=indent)
131
132
 
132
133
 
133
134
  def model_dump(
@@ -139,14 +140,14 @@ def model_dump(
139
140
  warnings: bool = True,
140
141
  mode: Literal["json", "python"] = "python",
141
142
  ) -> dict[str, Any]:
142
- if PYDANTIC_V2 or hasattr(model, "model_dump"):
143
+ if (not PYDANTIC_V1) or hasattr(model, "model_dump"):
143
144
  return model.model_dump(
144
145
  mode=mode,
145
146
  exclude=exclude,
146
147
  exclude_unset=exclude_unset,
147
148
  exclude_defaults=exclude_defaults,
148
149
  # warnings are not supported in Pydantic v1
149
- warnings=warnings if PYDANTIC_V2 else True,
150
+ warnings=True if PYDANTIC_V1 else warnings,
150
151
  )
151
152
  return cast(
152
153
  "dict[str, Any]",
@@ -159,9 +160,9 @@ def model_dump(
159
160
 
160
161
 
161
162
  def model_parse(model: type[_ModelT], data: Any) -> _ModelT:
162
- if PYDANTIC_V2:
163
- return model.model_validate(data)
164
- return model.parse_obj(data) # pyright: ignore[reportDeprecated]
163
+ if PYDANTIC_V1:
164
+ return model.parse_obj(data) # pyright: ignore[reportDeprecated]
165
+ return model.model_validate(data)
165
166
 
166
167
 
167
168
  # generic models
@@ -170,17 +171,16 @@ if TYPE_CHECKING:
170
171
  class GenericModel(pydantic.BaseModel): ...
171
172
 
172
173
  else:
173
- if PYDANTIC_V2:
174
+ if PYDANTIC_V1:
175
+ import pydantic.generics
176
+
177
+ class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): ...
178
+ else:
174
179
  # there no longer needs to be a distinction in v2 but
175
180
  # we still have to create our own subclass to avoid
176
181
  # inconsistent MRO ordering errors
177
182
  class GenericModel(pydantic.BaseModel): ...
178
183
 
179
- else:
180
- import pydantic.generics
181
-
182
- class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): ...
183
-
184
184
 
185
185
  # cached properties
186
186
  if TYPE_CHECKING: