|
8 | 8 | from pathlib import Path |
9 | 9 | from typing import Any, Generator |
10 | 10 | from urllib.parse import urlencode |
| 11 | +from warnings import warn |
11 | 12 |
|
12 | 13 | import aiofiles |
13 | 14 | from httpx import AsyncClient, Client |
@@ -1728,6 +1729,10 @@ async def update_settings(self, body: MeilisearchSettings) -> TaskInfo: |
1728 | 1729 | if is_pydantic_2(): |
1729 | 1730 | body_dict = {k: v for k, v in body.model_dump(by_alias=True).items() if v is not None} # type: ignore[attr-defined] |
1730 | 1731 | else: # pragma: no cover |
| 1732 | + warn( |
| 1733 | + "The use of Pydantic less than version 2 is depreciated and will be removed in a future release", |
| 1734 | + DeprecationWarning, |
| 1735 | + ) |
1731 | 1736 | body_dict = {k: v for k, v in body.dict(by_alias=True).items() if v is not None} # type: ignore[attr-defined] |
1732 | 1737 |
|
1733 | 1738 | response = await self._http_requests.patch(self._settings_url, body_dict) |
@@ -2428,6 +2433,10 @@ async def update_typo_tolerance(self, typo_tolerance: TypoTolerance) -> TaskInfo |
2428 | 2433 | f"{self._settings_url}/typo-tolerance", typo_tolerance.model_dump(by_alias=True) |
2429 | 2434 | ) # type: ignore[attr-defined] |
2430 | 2435 | else: # pragma: no cover |
| 2436 | + warn( |
| 2437 | + "The use of Pydantic less than version 2 is depreciated and will be removed in a future release", |
| 2438 | + DeprecationWarning, |
| 2439 | + ) |
2431 | 2440 | response = await self._http_requests.patch( |
2432 | 2441 | f"{self._settings_url}/typo-tolerance", typo_tolerance.dict(by_alias=True) |
2433 | 2442 | ) # type: ignore[attr-defined] |
@@ -2508,6 +2517,10 @@ async def update_faceting(self, faceting: Faceting) -> TaskInfo: |
2508 | 2517 | f"{self._settings_url}/faceting", faceting.model_dump(by_alias=True) |
2509 | 2518 | ) # type: ignore[attr-defined] |
2510 | 2519 | else: # pragma: no cover |
| 2520 | + warn( |
| 2521 | + "The use of Pydantic less than version 2 is depreciated and will be removed in a future release", |
| 2522 | + DeprecationWarning, |
| 2523 | + ) |
2511 | 2524 | response = await self._http_requests.patch( |
2512 | 2525 | f"{self._settings_url}/faceting", faceting.dict(by_alias=True) |
2513 | 2526 | ) # type: ignore[attr-defined] |
@@ -2589,6 +2602,10 @@ async def update_pagination(self, settings: Pagination) -> TaskInfo: |
2589 | 2602 | f"{self._settings_url}/pagination", settings.model_dump(by_alias=True) |
2590 | 2603 | ) # type: ignore[attr-defined] |
2591 | 2604 | else: # pragma: no cover |
| 2605 | + warn( |
| 2606 | + "The use of Pydantic less than version 2 is depreciated and will be removed in a future release", |
| 2607 | + DeprecationWarning, |
| 2608 | + ) |
2592 | 2609 | response = await self._http_requests.patch( |
2593 | 2610 | f"{self._settings_url}/pagination", settings.dict(by_alias=True) |
2594 | 2611 | ) # type: ignore[attr-defined] |
@@ -4367,6 +4384,10 @@ def update_settings(self, body: MeilisearchSettings) -> TaskInfo: |
4367 | 4384 | if is_pydantic_2(): |
4368 | 4385 | body_dict = {k: v for k, v in body.model_dump(by_alias=True).items() if v is not None} # type: ignore[attr-defined] |
4369 | 4386 | else: # pragma: no cover |
| 4387 | + warn( |
| 4388 | + "The use of Pydantic less than version 2 is depreciated and will be removed in a future release", |
| 4389 | + DeprecationWarning, |
| 4390 | + ) |
4370 | 4391 | body_dict = {k: v for k, v in body.dict(by_alias=True).items() if v is not None} # type: ignore[attr-defined] |
4371 | 4392 |
|
4372 | 4393 | response = self._http_requests.patch(self._settings_url, body_dict) |
@@ -5061,6 +5082,10 @@ def update_typo_tolerance(self, typo_tolerance: TypoTolerance) -> TaskInfo: |
5061 | 5082 | f"{self._settings_url}/typo-tolerance", typo_tolerance.model_dump(by_alias=True) |
5062 | 5083 | ) # type: ignore[attr-defined] |
5063 | 5084 | else: # pragma: no cover |
| 5085 | + warn( |
| 5086 | + "The use of Pydantic less than version 2 is depreciated and will be removed in a future release", |
| 5087 | + DeprecationWarning, |
| 5088 | + ) |
5064 | 5089 | response = self._http_requests.patch( |
5065 | 5090 | f"{self._settings_url}/typo-tolerance", typo_tolerance.dict(by_alias=True) |
5066 | 5091 | ) # type: ignore[attr-defined] |
@@ -5141,6 +5166,10 @@ def update_faceting(self, faceting: Faceting) -> TaskInfo: |
5141 | 5166 | f"{self._settings_url}/faceting", faceting.model_dump(by_alias=True) |
5142 | 5167 | ) # type: ignore[attr-defined] |
5143 | 5168 | else: # pragma: no cover |
| 5169 | + warn( |
| 5170 | + "The use of Pydantic less than version 2 is depreciated and will be removed in a future release", |
| 5171 | + DeprecationWarning, |
| 5172 | + ) |
5144 | 5173 | response = self._http_requests.patch( |
5145 | 5174 | f"{self._settings_url}/faceting", faceting.dict(by_alias=True) |
5146 | 5175 | ) # type: ignore[attr-defined] |
@@ -5222,6 +5251,10 @@ def update_pagination(self, settings: Pagination) -> TaskInfo: |
5222 | 5251 | f"{self._settings_url}/pagination", settings.model_dump(by_alias=True) |
5223 | 5252 | ) # type: ignore[attr-defined] |
5224 | 5253 | else: # pragma: no cover |
| 5254 | + warn( |
| 5255 | + "The use of Pydantic less than version 2 is depreciated and will be removed in a future release", |
| 5256 | + DeprecationWarning, |
| 5257 | + ) |
5225 | 5258 | response = self._http_requests.patch( |
5226 | 5259 | f"{self._settings_url}/pagination", settings.dict(by_alias=True) |
5227 | 5260 | ) # type: ignore[attr-defined] |
|
0 commit comments