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

Add search classes to strict type checking #1841

Merged
merged 5 commits into from
May 14, 2024

Conversation

jonathangreen
Copy link
Member

Description

Our search document classes were already typed, they were just missing a few hints necessary to add them to the list of classes that opt into strict type checking.

Motivation and Context

Since I'm working on these classes in PP-1225 I added the missing hints here.

How Has This Been Tested?

  • Running tests

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@jonathangreen jonathangreen requested a review from a team May 13, 2024 14:07
Copy link

codecov bot commented May 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.12%. Comparing base (25a5866) to head (7a8d100).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1841      +/-   ##
==========================================
- Coverage   90.12%   90.12%   -0.01%     
==========================================
  Files         300      300              
  Lines       39563    39569       +6     
  Branches     8595     8595              
==========================================
+ Hits        35657    35662       +5     
  Misses       2585     2585              
- Partials     1321     1322       +1     

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

Copy link
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

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

Looks good! 👍🏽

One small comment.

for name in result.keys():
if name.startswith(f"{self.base_revision_name}-"):
return name
return name # type: ignore[no-any-return]
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm. It looks like name should be a str here.

Copy link
Member Author

Choose a reason for hiding this comment

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

From what I could see client is untyped so self._client.indices.get_alias ends up giving us an Any type, which means name ends up being Any. I type hinted the returned dict, so we get a better type then Any.

@jonathangreen jonathangreen force-pushed the chore/add-type-hints-search-classes branch from 7c352bc to e76cfec Compare May 14, 2024 15:22
@jonathangreen jonathangreen force-pushed the chore/add-type-hints-search-classes branch from e76cfec to 7a8d100 Compare May 14, 2024 15:38
@jonathangreen jonathangreen merged commit 099c4ab into main May 14, 2024
20 checks passed
@jonathangreen jonathangreen deleted the chore/add-type-hints-search-classes branch May 14, 2024 15:53
jonathangreen added a commit that referenced this pull request May 24, 2024
* Add type hints to search classes
* Set future annotations
* Update to string annotations
* Don't use recursive type references, due to ugly syntax and incompatibility with union operator
* update type hint a bit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants