Skip to content
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

Supports typing around documents with Mapping #896

Merged
merged 5 commits into from
Dec 6, 2023

Conversation

geeksambhu
Copy link
Contributor

Pull Request

Related issue

Fixes #888

What does this PR do?

  • This PR changes the type hinting for documents in function parameters of functions like update_documents with typing.Mapping.

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Copy link
Collaborator

@sanders41 sanders41 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @geeksambhu

There are a few more places we can make this same update in both index.py and client.py where the parameter types are Dict[str, Any]. I believe the parameter names for these will all be either options or parameters but there could be some more I'm not thinking about.

meilisearch/_httprequests.py Outdated Show resolved Hide resolved
meilisearch/_httprequests.py Outdated Show resolved Hide resolved
meilisearch/_httprequests.py Outdated Show resolved Hide resolved
meilisearch/_httprequests.py Outdated Show resolved Hide resolved
meilisearch/_httprequests.py Outdated Show resolved Hide resolved
@sanders41
Copy link
Collaborator

Don't worry about the failed tests, they are all because codecov had an issue uploading and not because of any changes you made. They will pass (or I will get them to pass with a re-run) with the next round of updates.

@geeksambhu
Copy link
Contributor Author

@sanders41 I have added Mapping type for options and parameters in client & index, However, there are other Dict[str, Any] types in parameters such as body, queries, search_rules. Do we need to update these parameters as well?

@sanders41
Copy link
Collaborator

Anything in any of the files in models can stay Dict[str, Any], if you found some outside there (which I think you did) let's go ahead and change them.

Copy link

codecov bot commented Dec 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fb501e7) 100.00% compared to head (0167a68) 100.00%.
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #896   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        13           
  Lines          748       748           
=========================================
  Hits           748       748           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@geeksambhu
Copy link
Contributor Author

geeksambhu commented Dec 6, 2023

@sanders41, FYI: I updated some function parameters with MutableMapping type as these parameters were modified within the method/function body.

@geeksambhu geeksambhu requested a review from sanders41 December 6, 2023 18:37
@sanders41
Copy link
Collaborator

@sanders41, FYI: I updated some function parameters with MutableMapping type as these parameters were modified within the method/function body.

Perfect!

Copy link
Collaborator

@sanders41 sanders41 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sanders41
Copy link
Collaborator

bors merge

@sanders41 sanders41 added the enhancement New feature or request label Dec 6, 2023
Copy link
Contributor

meili-bors bot commented Dec 6, 2023

@meili-bors meili-bors bot merged commit 26f3208 into meilisearch:main Dec 6, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typing around documents should be Mapping[] not Dict[]
2 participants