meilisearch-python-sdk 2.11.1__py3-none-any.whl → 2.12.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.

Potentially problematic release.


This version of meilisearch-python-sdk might be problematic. Click here for more details.

@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import json
4
4
  from datetime import datetime, timezone
5
5
  from ssl import SSLContext
6
- from types import TracebackType
6
+ from typing import TYPE_CHECKING
7
7
  from warnings import warn
8
8
 
9
9
  import jwt
@@ -29,19 +29,34 @@ from meilisearch_python_sdk.models.settings import MeilisearchSettings
29
29
  from meilisearch_python_sdk.models.task import TaskInfo, TaskResult, TaskStatus
30
30
  from meilisearch_python_sdk.models.version import Version
31
31
  from meilisearch_python_sdk.plugins import AsyncIndexPlugins, IndexPlugins
32
- from meilisearch_python_sdk.types import JsonDict, JsonMapping
32
+
33
+ if TYPE_CHECKING: # pragma: no cover
34
+ import sys
35
+ from types import TracebackType
36
+
37
+ from meilisearch_python_sdk.types import JsonDict, JsonMapping
38
+
39
+ if sys.version_info >= (3, 11):
40
+ from typing import Self
41
+ else:
42
+ from typing_extensions import Self
33
43
 
34
44
 
35
45
  class BaseClient:
36
46
  def __init__(
37
47
  self,
38
48
  api_key: str | None = None,
49
+ custom_headers: dict[str, str] | None = None,
39
50
  ) -> None:
40
- self._headers: dict[str, str] | None
51
+ self._headers: dict[str, str] | None = None
41
52
  if api_key:
42
53
  self._headers = {"Authorization": f"Bearer {api_key}"}
43
- else:
44
- self._headers = None
54
+
55
+ if custom_headers:
56
+ if self._headers:
57
+ self._headers.update(custom_headers)
58
+ else:
59
+ self._headers = custom_headers
45
60
 
46
61
  def generate_tenant_token(
47
62
  self,
@@ -127,6 +142,7 @@ class AsyncClient(BaseClient):
127
142
  *,
128
143
  timeout: int | None = None,
129
144
  verify: str | bool | SSLContext = True,
145
+ custom_headers: dict[str, str] | None = None,
130
146
  ) -> None:
131
147
  """Class initializer.
132
148
 
@@ -139,15 +155,17 @@ class AsyncClient(BaseClient):
139
155
  verify: SSL certificates (a.k.a CA bundle) used to
140
156
  verify the identity of requested hosts. Either `True` (default CA bundle),
141
157
  a path to an SSL certificate file, or `False` (disable verification)
158
+ custom_headers: Custom headers to add when sending data to Meilisearch. Defaults to
159
+ None.
142
160
  """
143
- super().__init__(api_key)
161
+ super().__init__(api_key, custom_headers)
144
162
 
145
163
  self.http_client = HttpxAsyncClient(
146
164
  base_url=url, timeout=timeout, headers=self._headers, verify=verify
147
165
  )
148
166
  self._http_requests = AsyncHttpRequests(self.http_client)
149
167
 
150
- async def __aenter__(self) -> AsyncClient:
168
+ async def __aenter__(self) -> Self:
151
169
  return self
152
170
 
153
171
  async def __aexit__(
@@ -1016,6 +1034,7 @@ class Client(BaseClient):
1016
1034
  *,
1017
1035
  timeout: int | None = None,
1018
1036
  verify: str | bool | SSLContext = True,
1037
+ custom_headers: dict[str, str] | None = None,
1019
1038
  ) -> None:
1020
1039
  """Class initializer.
1021
1040
 
@@ -1028,8 +1047,10 @@ class Client(BaseClient):
1028
1047
  verify: SSL certificates (a.k.a CA bundle) used to
1029
1048
  verify the identity of requested hosts. Either `True` (default CA bundle),
1030
1049
  a path to an SSL certificate file, or `False` (disable verification)
1050
+ custom_headers: Custom headers to add when sending data to Meilisearch. Defaults to
1051
+ None.
1031
1052
  """
1032
- super().__init__(api_key)
1053
+ super().__init__(api_key, custom_headers)
1033
1054
 
1034
1055
  self.http_client = HttpxClient(
1035
1056
  base_url=url, timeout=timeout, headers=self._headers, verify=verify
@@ -1 +1 @@
1
- VERSION = "2.11.1"
1
+ VERSION = "2.12.0"
@@ -54,8 +54,15 @@ from meilisearch_python_sdk.plugins import (
54
54
  )
55
55
 
56
56
  if TYPE_CHECKING: # pragma: no cover
57
+ import sys
58
+
57
59
  from meilisearch_python_sdk.types import Filter, JsonDict, JsonMapping
58
60
 
61
+ if sys.version_info >= (3, 11):
62
+ from typing import Self
63
+ else:
64
+ from typing_extensions import Self
65
+
59
66
 
60
67
  class _BaseIndex:
61
68
  def __init__(
@@ -533,7 +540,7 @@ class AsyncIndex(_BaseIndex):
533
540
 
534
541
  return False
535
542
 
536
- async def update(self, primary_key: str) -> AsyncIndex:
543
+ async def update(self, primary_key: str) -> Self:
537
544
  """Update the index primary key.
538
545
 
539
546
  Args:
@@ -565,7 +572,7 @@ class AsyncIndex(_BaseIndex):
565
572
  self.primary_key = index_response.json()["primaryKey"]
566
573
  return self
567
574
 
568
- async def fetch_info(self) -> AsyncIndex:
575
+ async def fetch_info(self) -> Self:
569
576
  """Gets the infromation about the index.
570
577
 
571
578
  Returns:
@@ -624,7 +631,7 @@ class AsyncIndex(_BaseIndex):
624
631
  wait: bool = True,
625
632
  timeout_in_ms: int | None = None,
626
633
  plugins: AsyncIndexPlugins | None = None,
627
- ) -> AsyncIndex:
634
+ ) -> Self:
628
635
  """Creates a new index.
629
636
 
630
637
  In general this method should not be used directly and instead the index should be created
@@ -4905,7 +4912,7 @@ class Index(_BaseIndex):
4905
4912
 
4906
4913
  return False
4907
4914
 
4908
- def update(self, primary_key: str) -> Index:
4915
+ def update(self, primary_key: str) -> Self:
4909
4916
  """Update the index primary key.
4910
4917
 
4911
4918
  Args:
@@ -4935,7 +4942,7 @@ class Index(_BaseIndex):
4935
4942
  self.primary_key = index_response.json()["primaryKey"]
4936
4943
  return self
4937
4944
 
4938
- def fetch_info(self) -> Index:
4945
+ def fetch_info(self) -> Self:
4939
4946
  """Gets the infromation about the index.
4940
4947
 
4941
4948
  Returns:
@@ -4994,7 +5001,7 @@ class Index(_BaseIndex):
4994
5001
  wait: bool = True,
4995
5002
  timeout_in_ms: int | None = None,
4996
5003
  plugins: IndexPlugins | None = None,
4997
- ) -> Index:
5004
+ ) -> Self:
4998
5005
  """Creates a new index.
4999
5006
 
5000
5007
  In general this method should not be used directly and instead the index should be created
@@ -1,5 +1,11 @@
1
+ import sys
1
2
  from typing import Any, Dict, List, MutableMapping, Union
2
3
 
3
- Filter = Union[str, List[Union[str, List[str]]]]
4
- JsonDict = Dict[str, Any]
5
- JsonMapping = MutableMapping[str, Any]
4
+ if sys.version_info >= (3, 10): # pragma: no cover
5
+ from typing import TypeAlias
6
+ else:
7
+ from typing_extensions import TypeAlias
8
+
9
+ Filter: TypeAlias = Union[str, List[Union[str, List[str]]]]
10
+ JsonDict: TypeAlias = Dict[str, Any]
11
+ JsonMapping: TypeAlias = MutableMapping[str, Any]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: meilisearch-python-sdk
3
- Version: 2.11.1
3
+ Version: 2.12.0
4
4
  Summary: A Python client providing both async and sync support for the Meilisearch API
5
5
  Home-page: https://github.com/sanders41/meilisearch-python-sdk
6
6
  License: MIT
@@ -1,12 +1,12 @@
1
1
  meilisearch_python_sdk/__init__.py,sha256=SB0Jlm6FwT13J9xasZKseZzTWBk0hkfe1CWyWmIIZnE,258
2
- meilisearch_python_sdk/_client.py,sha256=uUwIsqr47_a4XaElsP2ew0H-M4VGNHOUNNwNpW9CtYw,66791
2
+ meilisearch_python_sdk/_client.py,sha256=UuTYt5qPh0N5ziuRawSJhz_rharRkmIew-lTjHeR7nE,67568
3
3
  meilisearch_python_sdk/_http_requests.py,sha256=codxloe8PeV1e7WCzC9N_DDMJu5_UqSRZl2g4f8O9hE,7073
4
4
  meilisearch_python_sdk/_task.py,sha256=HiyrLsQn5O2PlnUsKPc0RLSPZnJMIsiwA3WSmFsU2Qk,11874
5
5
  meilisearch_python_sdk/_utils.py,sha256=SMoBWDlLtAEtpD8n94CCcHvtBA-HLWyolxPY-n4K_UE,1610
6
- meilisearch_python_sdk/_version.py,sha256=HBjUBr8Pc7t7KGSSL56EtHb3w2c4ELcCtsap2ibZD7g,19
6
+ meilisearch_python_sdk/_version.py,sha256=Oims9BkxGWftvFLEp8GVkzcqnafuqqtIAC-q_iATlUc,19
7
7
  meilisearch_python_sdk/decorators.py,sha256=KpS5gAgks28BtPMZJumRaXfgXK4A3QNVPR8Z4BpZC0g,8346
8
8
  meilisearch_python_sdk/errors.py,sha256=0sAKYt47-zFpKsEU6W8Qnvf4uHBynKtlGPpPl-5laSA,2085
9
- meilisearch_python_sdk/index.py,sha256=USNG8RqmyIuhVhZB0Ba3Uirm18Wm9PeCIDuKT3OlKzE,323068
9
+ meilisearch_python_sdk/index.py,sha256=OnMb-K1MTa-CFt4HbMYzUR7Q-gEZ2UFYgXbu8AKJoeI,323185
10
10
  meilisearch_python_sdk/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  meilisearch_python_sdk/models/client.py,sha256=Ka-BgBXmWGqwRm95r2y-vJYFm95fgDamXlPXdfBVvzo,5700
12
12
  meilisearch_python_sdk/models/documents.py,sha256=1X6y-gPRD1sB8V-2b-c-gOmQEs-yR8e7ZiY5TWwFNBs,236
@@ -18,8 +18,8 @@ meilisearch_python_sdk/models/task.py,sha256=6wVY6M9HlIjMaMUMq63RbcsnqOBWrDVUBDw
18
18
  meilisearch_python_sdk/models/version.py,sha256=YDu-aj5H-d6nSaWRTXzlwWghmZAoiknaw250UyEd48I,215
19
19
  meilisearch_python_sdk/plugins.py,sha256=qfc5smEvOqYV_okdcmnJgDszCzOpmUPG1oA2UYCw5dE,3580
20
20
  meilisearch_python_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- meilisearch_python_sdk/types.py,sha256=BoZcEdkazGKp3Hh6h5yMDtDBLYjOQjQW3SH0cO8k8kw,173
22
- meilisearch_python_sdk-2.11.1.dist-info/LICENSE,sha256=xVzevI1TrlKfM0plmJ7vfK1Muu0V9n-dGE8RnDrOFlM,1069
23
- meilisearch_python_sdk-2.11.1.dist-info/METADATA,sha256=UyYQ3H8UbxhMRs5z2xFkO0WNWpkktXL1D40vpz4Udjo,8265
24
- meilisearch_python_sdk-2.11.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
25
- meilisearch_python_sdk-2.11.1.dist-info/RECORD,,
21
+ meilisearch_python_sdk/types.py,sha256=qQV3sOaUDm5xwY8nsLtusObDvDO-I8jSNMiaNqQn-W0,353
22
+ meilisearch_python_sdk-2.12.0.dist-info/LICENSE,sha256=xVzevI1TrlKfM0plmJ7vfK1Muu0V9n-dGE8RnDrOFlM,1069
23
+ meilisearch_python_sdk-2.12.0.dist-info/METADATA,sha256=rQx3bDg4mp58U_KYFUYaB5KenkeB68ps-b6JF1xIJ9g,8265
24
+ meilisearch_python_sdk-2.12.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
25
+ meilisearch_python_sdk-2.12.0.dist-info/RECORD,,