Skip to content

Commit ec0baf9

Browse files
bors[bot]Dark-Rockalallema
authored
Merge #564
564: Inconsistencies fix r=alallema a=Dark-Rock # Pull Request ## Related issue Fixes #563 ## What does this PR do? - Fixed the inconsistencies using black throughout the project. This changed the single quote to double quote (Human readibility reasons), fixed the parenthesis anomaly and improved readibility of the code base. ## PR checklist Please check if your PR fulfills the following requirements: - [X] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [X] Have you read the contributing guidelines? - [X] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: JeremyNgu108 <[email protected]> Co-authored-by: Dark-Rock <[email protected]> Co-authored-by: Amélie <[email protected]>
2 parents 06742bc + 112596c commit ec0baf9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1220
-1026
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ pipenv install --dev
5757
### Tests and Linter <!-- omit in toc -->
5858

5959
Each PR should pass the tests, mypy type checking, and the linter to be accepted.
60+
Your PR also needs to be formatted using black and isort.
6061

6162
```bash
6263
# Tests
@@ -67,6 +68,10 @@ pipenv run pytest tests
6768
pipenv run mypy meilisearch
6869
# Linter
6970
pipenv run pylint meilisearch
71+
# Black
72+
pipenv run black meilisearch tests
73+
# Isort
74+
pipenv run isort meilisearch tests
7075
```
7176

7277
Optionally tox can be used to run test on all supported version of Python, mypy, and linting.

Pipfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ pytest-ordering = "*"
1212
tox = "*"
1313
tox-pipenv = "*"
1414
types-requests = "*"
15+
black = "*"
16+
isort = "*"
1517

1618
[packages]
1719
requests = "*"

Pipfile.lock

Lines changed: 62 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/conf.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
#
1313
import os
1414
import sys
15-
sys.path.insert(0, os.path.abspath('..'))
15+
16+
sys.path.insert(0, os.path.abspath(".."))
1617

1718
# -- Project information -----------------------------------------------------
1819

19-
project = 'meilisearch-python'
20-
copyright = '2019, Meili SAS'
21-
author = 'Charlotte Vermandel'
20+
project = "meilisearch-python"
21+
copyright = "2019, Meili SAS"
22+
author = "Charlotte Vermandel"
2223

2324

2425
# -- General configuration ---------------------------------------------------
@@ -27,27 +28,27 @@
2728
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2829
# ones.
2930
extensions = [
30-
'sphinx.ext.autodoc',
31-
'sphinx.ext.napoleon',
32-
'sphinx.ext.viewcode',
31+
"sphinx.ext.autodoc",
32+
"sphinx.ext.napoleon",
33+
"sphinx.ext.viewcode",
3334
]
3435

3536
# Add any paths that contain templates here, relative to this directory.
36-
templates_path = ['_templates']
37+
templates_path = ["_templates"]
3738

3839
# List of patterns, relative to source directory, that match files and
3940
# directories to ignore when looking for source files.
4041
# This pattern also affects html_static_path and html_extra_path.
41-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
42+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4243

4344

4445
# -- Options for HTML output -------------------------------------------------
4546

4647
# The theme to use for HTML and HTML Help pages. See the documentation for
4748
# a list of builtin themes.
4849
#
49-
html_theme = 'sphinx_rtd_theme'
50-
#html_theme = 'alabaster'
50+
html_theme = "sphinx_rtd_theme"
51+
# html_theme = 'alabaster'
5152

5253
# Add any paths that contain custom static files (such as style sheets) here,
5354
# relative to this directory. They are copied after the builtin static files,

meilisearch/_httprequests.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class HttpRequests:
1818
def __init__(self, config: Config) -> None:
1919
self.config = config
2020
self.headers = {
21-
'Authorization': f'Bearer {self.config.api_key}',
22-
'User-Agent': qualified_version(),
21+
"Authorization": f"Bearer {self.config.api_key}",
22+
"User-Agent": qualified_version(),
2323
}
2424

2525
def send_request(
@@ -30,22 +30,22 @@ def send_request(
3030
content_type: str | None = None,
3131
) -> Any:
3232
if content_type:
33-
self.headers['Content-Type'] = content_type
33+
self.headers["Content-Type"] = content_type
3434
try:
35-
request_path = self.config.url + '/' + path
35+
request_path = self.config.url + "/" + path
3636
if isinstance(body, bytes):
3737
request = http_method(
3838
request_path,
3939
timeout=self.config.timeout,
4040
headers=self.headers,
41-
data=body
41+
data=body,
4242
)
4343
else:
4444
request = http_method(
4545
request_path,
4646
timeout=self.config.timeout,
4747
headers=self.headers,
48-
data=json.dumps(body) if body else "null"
48+
data=json.dumps(body) if body else "null",
4949
)
5050
return self.__validate(request)
5151

@@ -54,32 +54,30 @@ def send_request(
5454
except requests.exceptions.ConnectionError as err:
5555
raise MeiliSearchCommunicationError(str(err)) from err
5656

57-
def get(
58-
self, path: str
59-
) -> Any:
57+
def get(self, path: str) -> Any:
6058
return self.send_request(requests.get, path)
6159

6260
def post(
6361
self,
6462
path: str,
6563
body: dict[str, Any] | list[dict[str, Any]] | list[str] | str | None = None,
66-
content_type: str | None = 'application/json',
64+
content_type: str | None = "application/json",
6765
) -> Any:
6866
return self.send_request(requests.post, path, body, content_type)
6967

7068
def patch(
7169
self,
7270
path: str,
7371
body: dict[str, Any] | list[dict[str, Any]] | list[str] | str | None = None,
74-
content_type: str | None = 'application/json',
72+
content_type: str | None = "application/json",
7573
) -> Any:
7674
return self.send_request(requests.patch, path, body, content_type)
7775

7876
def put(
7977
self,
8078
path: str,
8179
body: dict[str, Any] | list[dict[str, Any]] | list[str] | str | None = None,
82-
content_type: str | None = 'application/json',
80+
content_type: str | None = "application/json",
8381
) -> Any:
8482
return self.send_request(requests.put, path, body, content_type)
8583

@@ -91,17 +89,13 @@ def delete(
9189
return self.send_request(requests.delete, path, body)
9290

9391
@staticmethod
94-
def __to_json(
95-
request: requests.Response
96-
) -> Any:
97-
if request.content == b'':
92+
def __to_json(request: requests.Response) -> Any:
93+
if request.content == b"":
9894
return request
9995
return request.json()
10096

10197
@staticmethod
102-
def __validate(
103-
request: requests.Response
104-
) -> Any:
98+
def __validate(request: requests.Response) -> Any:
10599
try:
106100
request.raise_for_status()
107101
return HttpRequests.__to_json(request)

0 commit comments

Comments
 (0)