Skip to content

Commit 7db8aa1

Browse files
committed
Drop python 3.6 support
1 parent f5403e5 commit 7db8aa1

24 files changed

+179
-156
lines changed

.github/workflows/pre-release-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
python-version: [3.6, 3.7, 3.8, 3.9, '3.10.0-beta - 3.10.0']
16+
python-version: ["3.7", "3.8", "3.9", "3.10"]
1717
name: integration-tests-against-rc
1818
runs-on: ubuntu-latest
1919
steps:

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
python-version: [3.6, 3.7, 3.8, 3.9, '3.10.0-beta - 3.10.0']
20+
python-version: ["3.7", "3.8", "3.9", "3.10"]
2121
name: integration-tests
2222
runs-on: ubuntu-latest
2323
steps:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ See our [Documentation](https://docs.meilisearch.com/learn/tutorials/getting_sta
4141

4242
## 🔧 Installation
4343

44-
**Note**: Python 3.6+ is required.
44+
**Note**: Python 3.7+ is required.
4545

4646
With `pip3` in command line:
4747

bors.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
status = [
22
'pylint',
33
'mypy',
4-
'integration-tests (3.6)',
54
'integration-tests (3.7)',
65
'integration-tests (3.8)',
76
'integration-tests (3.9)'
7+
'integration-tests (3.10)'
88
]
99
# 1 hour timeout
1010
timeout-sec = 3600

meilisearch/_httprequests.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
from __future__ import annotations
2+
13
import json
2-
from typing import Any, Callable, Dict, List, Optional, Union
4+
from typing import Any, Callable
5+
36
import requests
7+
48
from meilisearch.config import Config
59
from meilisearch.errors import (
610
MeiliSearchApiError,
@@ -9,6 +13,7 @@
913
)
1014
from meilisearch.version import qualified_version
1115

16+
1217
class HttpRequests:
1318
def __init__(self, config: Config) -> None:
1419
self.config = config
@@ -21,8 +26,8 @@ def send_request(
2126
self,
2227
http_method: Callable,
2328
path: str,
24-
body: Optional[Union[Dict[str, Any], List[Dict[str, Any]], List[str], str]] = None,
25-
content_type: Optional[str] = None,
29+
body: dict[str, Any] | list[dict[str, Any]] | list[str] | str | None = None,
30+
content_type: str | None = None,
2631
) -> Any:
2732
if content_type:
2833
self.headers['Content-Type'] = content_type
@@ -57,31 +62,31 @@ def get(
5762
def post(
5863
self,
5964
path: str,
60-
body: Optional[Union[Dict[str, Any], List[Dict[str, Any]], List[str], str]] = None,
61-
content_type: Optional[str] = 'application/json',
65+
body: dict[str, Any] | list[dict[str, Any]] | list[str] | str | None = None,
66+
content_type: str | None = 'application/json',
6267
) -> Any:
6368
return self.send_request(requests.post, path, body, content_type)
6469

6570
def patch(
6671
self,
6772
path: str,
68-
body: Optional[Union[Dict[str, Any], List[Dict[str, Any]], List[str], str]] = None,
69-
content_type: Optional[str] = 'application/json',
73+
body: dict[str, Any] | list[dict[str, Any]] | list[str] | str | None = None,
74+
content_type: str | None = 'application/json',
7075
) -> Any:
7176
return self.send_request(requests.patch, path, body, content_type)
7277

7378
def put(
7479
self,
7580
path: str,
76-
body: Optional[Union[Dict[str, Any], List[Dict[str, Any]], List[str]]] = None,
77-
content_type: Optional[str] = 'application/json',
81+
body: dict[str, Any] | list[dict[str, Any]] | list[str] | None = None,
82+
content_type: str | None = 'application/json',
7883
) -> Any:
7984
return self.send_request(requests.put, path, body, content_type)
8085

8186
def delete(
8287
self,
8388
path: str,
84-
body: Optional[Union[Dict[str, Any], List[Dict[str, Any]], List[str]]] = None,
89+
body: dict[str, Any] | list[dict[str, Any]] | list[str] | None = None,
8590
) -> Any:
8691
return self.send_request(requests.delete, path, body)
8792

meilisearch/client.py

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
import re
1+
from __future__ import annotations
2+
23
import base64
4+
import datetime
35
import hashlib
46
import hmac
57
import json
6-
import datetime
8+
import re
9+
from typing import Any
710
from urllib import parse
8-
from typing import Any, Dict, List, Optional, Union
9-
from meilisearch.index import Index
10-
from meilisearch.config import Config
11-
from meilisearch.task import get_task, get_tasks, wait_for_task
11+
1212
from meilisearch._httprequests import HttpRequests
13+
from meilisearch.config import Config
1314
from meilisearch.errors import MeiliSearchError
15+
from meilisearch.index import Index
16+
from meilisearch.task import get_task, get_tasks, wait_for_task
17+
1418

1519
class Client():
1620
"""
@@ -21,7 +25,7 @@ class Client():
2125
"""
2226

2327
def __init__(
24-
self, url: str, api_key: Optional[str] = None, timeout: Optional[int] = None
28+
self, url: str, api_key: str | None = None, timeout: int | None = None
2529
) -> None:
2630
"""
2731
Parameters
@@ -35,7 +39,7 @@ def __init__(
3539

3640
self.http = HttpRequests(self.config)
3741

38-
def create_index(self, uid: str, options: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
42+
def create_index(self, uid: str, options: dict[str, Any] | None = None) -> dict[str, Any]:
3943
"""Create an index.
4044
4145
Parameters
@@ -58,7 +62,7 @@ def create_index(self, uid: str, options: Optional[Dict[str, Any]] = None) -> Di
5862
"""
5963
return Index.create(self.config, uid, options)
6064

61-
def delete_index(self, uid: str) -> Dict[str, Any]:
65+
def delete_index(self, uid: str) -> dict[str, Any]:
6266
"""Deletes an index
6367
6468
Parameters
@@ -80,7 +84,7 @@ def delete_index(self, uid: str) -> Dict[str, Any]:
8084

8185
return self.http.delete(f'{self.config.paths.index}/{uid}')
8286

83-
def get_indexes(self, parameters: Optional[Dict[str, Any]] = None) -> Dict[str, List[Index]]:
87+
def get_indexes(self, parameters: dict[str, Any] | None = None) -> dict[str, list[Index]]:
8488
"""Get all indexes.
8589
8690
Parameters
@@ -115,7 +119,7 @@ def get_indexes(self, parameters: Optional[Dict[str, Any]] = None) -> Dict[str,
115119
]
116120
return response
117121

118-
def get_raw_indexes(self, parameters: Optional[Dict[str, Any]] = None) -> List[Dict[str, Any]]:
122+
def get_raw_indexes(self, parameters: dict[str, Any] | None = None) -> list[dict[str, Any]]:
119123
"""Get all indexes in dictionary format.
120124
121125
Parameters
@@ -160,7 +164,7 @@ def get_index(self, uid: str) -> Index:
160164
"""
161165
return Index(self.config, uid).fetch_info()
162166

163-
def get_raw_index(self, uid: str) -> Dict[str, Any]:
167+
def get_raw_index(self, uid: str) -> dict[str, Any]:
164168
"""Get the index as a dictionary.
165169
This index should already exist.
166170
@@ -199,7 +203,7 @@ def index(self, uid: str) -> Index:
199203
return Index(self.config, uid=uid)
200204
raise Exception('The index UID should not be None')
201205

202-
def get_all_stats(self) -> Dict[str, Any]:
206+
def get_all_stats(self) -> dict[str, Any]:
203207
"""Get all stats of Meilisearch
204208
205209
Get information about database size and all indexes
@@ -217,7 +221,7 @@ def get_all_stats(self) -> Dict[str, Any]:
217221
"""
218222
return self.http.get(self.config.paths.stat)
219223

220-
def health(self) -> Dict[str, str]:
224+
def health(self) -> dict[str, str]:
221225
"""Get health of the Meilisearch server.
222226
223227
Returns
@@ -241,7 +245,7 @@ def is_healthy(self) -> bool:
241245
return False
242246
return True
243247

244-
def get_key(self, key_or_uid: str) -> Dict[str, Any]:
248+
def get_key(self, key_or_uid: str) -> dict[str, Any]:
245249
"""Gets information about a specific API key.
246250
247251
Parameters
@@ -262,7 +266,7 @@ def get_key(self, key_or_uid: str) -> Dict[str, Any]:
262266
"""
263267
return self.http.get(f'{self.config.paths.keys}/{key_or_uid}')
264268

265-
def get_keys(self, parameters: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
269+
def get_keys(self, parameters: dict[str, Any] | None = None) -> dict[str, Any]:
266270
"""Gets the Meilisearch API keys.
267271
268272
Parameters
@@ -289,8 +293,8 @@ def get_keys(self, parameters: Optional[Dict[str, Any]] = None) -> Dict[str, Any
289293

290294
def create_key(
291295
self,
292-
options: Dict[str, Any]
293-
) -> Dict[str, Any]:
296+
options: dict[str, Any]
297+
) -> dict[str, Any]:
294298
"""Creates a new API key.
295299
296300
Parameters
@@ -318,8 +322,8 @@ def create_key(
318322
def update_key(
319323
self,
320324
key_or_uid: str,
321-
options: Dict[str, Any]
322-
) -> Dict[str, Any]:
325+
options: dict[str, Any]
326+
) -> dict[str, Any]:
323327
"""Update an API key.
324328
325329
Parameters
@@ -345,7 +349,7 @@ def update_key(
345349
url = f'{self.config.paths.keys}/{key_or_uid}'
346350
return self.http.patch(url, options)
347351

348-
def delete_key(self, key_or_uid: str) -> Dict[str, int]:
352+
def delete_key(self, key_or_uid: str) -> dict[str, int]:
349353
"""Deletes an API key.
350354
351355
Parameters
@@ -366,7 +370,7 @@ def delete_key(self, key_or_uid: str) -> Dict[str, int]:
366370
"""
367371
return self.http.delete(f'{self.config.paths.keys}/{key_or_uid}')
368372

369-
def get_version(self) -> Dict[str, str]:
373+
def get_version(self) -> dict[str, str]:
370374
"""Get version Meilisearch
371375
372376
Returns
@@ -381,7 +385,7 @@ def get_version(self) -> Dict[str, str]:
381385
"""
382386
return self.http.get(self.config.paths.version)
383387

384-
def version(self) -> Dict[str, str]:
388+
def version(self) -> dict[str, str]:
385389
"""Alias for get_version
386390
387391
Returns
@@ -396,7 +400,7 @@ def version(self) -> Dict[str, str]:
396400
"""
397401
return self.get_version()
398402

399-
def create_dump(self) -> Dict[str, str]:
403+
def create_dump(self) -> dict[str, str]:
400404
"""Trigger the creation of a Meilisearch dump.
401405
402406
Returns
@@ -412,7 +416,7 @@ def create_dump(self) -> Dict[str, str]:
412416
"""
413417
return self.http.post(self.config.paths.dumps)
414418

415-
def get_tasks(self, parameters: Optional[Dict[str, Any]] = None) -> Dict[str, List[Dict[str, Any]]]:
419+
def get_tasks(self, parameters: dict[str, Any] | None = None) -> dict[str, list[dict[str, Any]]]:
416420
"""Get all tasks.
417421
418422
Parameters
@@ -433,7 +437,7 @@ def get_tasks(self, parameters: Optional[Dict[str, Any]] = None) -> Dict[str, Li
433437
"""
434438
return get_tasks(self.config, parameters=parameters)
435439

436-
def get_task(self, uid: int) -> Dict[str, Any]:
440+
def get_task(self, uid: int) -> dict[str, Any]:
437441
"""Get one task.
438442
439443
Parameters
@@ -457,7 +461,7 @@ def wait_for_task(
457461
self, uid: int,
458462
timeout_in_ms: int = 5000,
459463
interval_in_ms: int = 50,
460-
) -> Dict[str, Any]:
464+
) -> dict[str, Any]:
461465
"""Wait until Meilisearch processes a task until it fails or succeeds.
462466
463467
Parameters
@@ -484,10 +488,10 @@ def wait_for_task(
484488
def generate_tenant_token(
485489
self,
486490
api_key_uid: str,
487-
search_rules: Union[Dict[str, Any], List[str]],
491+
search_rules: dict[str, Any] | list[str],
488492
*,
489-
expires_at: Optional[datetime.datetime] = None,
490-
api_key: Optional[str] = None
493+
expires_at: datetime.datetime | None = None,
494+
api_key: str | None = None
491495
) -> str:
492496
"""Generate a JWT token for the use of multitenancy.
493497

meilisearch/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional
1+
from __future__ import annotations
22

33

44
class Config:
@@ -33,8 +33,8 @@ class Paths():
3333
def __init__(
3434
self,
3535
url: str,
36-
api_key: Optional[str] = None,
37-
timeout: Optional[int] = None
36+
api_key: str | None = None,
37+
timeout: int | None = None
3838
) -> None:
3939
"""
4040
Parameters

meilisearch/errors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
from __future__ import annotations
2+
13
import json
24

35
from requests import Response
46

7+
58
class MeiliSearchError(Exception):
69
"""Generic class for Meilisearch error handling"""
710

0 commit comments

Comments
 (0)