-
Notifications
You must be signed in to change notification settings - Fork 95
Adding type hints and mypy #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hello @sanders41, thanks a lot for your PR :) |
|
No problem, no hurry on my end. Sorry it's a big one I couldn't think of a good way to split it up. |
meilisearch/client.py
Outdated
| Returns | ||
| ------- | ||
| indexes: list | ||
| indexes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some colons are missing sometimes
meilisearch/index.py
Outdated
| return self.http.delete(f'{self.config.paths.index}/{self.uid}') | ||
|
|
||
| def update(self, **body): | ||
| def update(self, **body: Dict[str, Any]) -> "Index": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we exchange "Index" for 'Index'? It seems to me that it's better for string literals.
meilisearch/index.py
Outdated
| return self | ||
|
|
||
| def fetch_info(self): | ||
| def fetch_info(self) -> "Index": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also "Index" to 'Index'
meilisearch/_httprequests.py
Outdated
| @@ -1,20 +1,29 @@ | |||
| import json | |||
| from typing import Any, Callable, Dict, List, Optional, Union | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meilisearch/_httprequests.py
Outdated
| from typing import Any, Callable, Dict, List, Optional, Union | ||
|
|
||
| import requests | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meilisearch/index.py
Outdated
| Parameters | ||
| ---------- | ||
| uid: str | ||
| uid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| uid | |
| uid: |
meilisearch/index.py
Outdated
| uid | ||
| UID of the index. | ||
| options: dict, optional | ||
| options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| options | |
| options: |
meilisearch/index.py
Outdated
| Returns | ||
| ------- | ||
| update: dict | ||
| update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| update | |
| update: |
meilisearch/client.py
Outdated
| Returns | ||
| ------- | ||
| indexes: list | ||
| indexes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| indexes | |
| indexes: |
| mypy: | ||
| name: mypy | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v1 | ||
| - name: Set up Python 3.9 | ||
| uses: actions/setup-python@v1 | ||
| with: | ||
| python-version: 3.9 | ||
| - name: Install pipenv | ||
| uses: dschep/install-pipenv-action@v1 | ||
| - name: Install dependencies | ||
| run: pipenv install --dev | ||
| - name: mypy type check | ||
| run: pipenv run mypy meilisearch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your PR @sanders41!
Can you add the mypy check to bors too?
|
Hi @sanders41! I've just given you write access to this repo if you agree! It will avoid you to fork this project for the next contributions 🙂 Also, your reviews on PR will be taken into account by GitHub! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again @sanders41!
|
bors merge |
Closes #264
Unfortunately the methods in the
HttpRequestsclass can return so may different types, I was up to Union[dict[str, Any], List[Dict[str, Any]], List[str], List[int], str, requests.Response] and not done, that I had to go withAnywhich mean mypy wasn't able to check the return types from calls to methods in that class. Since those are the values that are usually returned from methods in theClientandIndexclasses that means mypy wasn't able to check those values. Luckily that class is only supposed to be used internally so code editors and users of the package will still get the benefits from the type hints and mypy. Developers of this package also still get the same benefits.