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

Provide overload type hints for search_issues variants #1861

Merged
merged 4 commits into from
Sep 2, 2024

Conversation

Stealthii
Copy link
Contributor

@Stealthii Stealthii commented May 22, 2024

search_issues can return either a dictionary (if json_result) or a list of Issues under default behavior.

This change provides separate hints using overload so that type checked code doesn't need to cast unnecessarily when dealing with output.

Tests have been added, and cases where casting was used have been removed.

Fixes #1608.

@Stealthii Stealthii marked this pull request as draft May 22, 2024 09:48
@Stealthii Stealthii changed the title Correct type hints for search_issues Provide overload type hints for search_issues variants May 22, 2024
@Stealthii Stealthii marked this pull request as ready for review May 23, 2024 07:58
@Stealthii
Copy link
Contributor Author

The cloud / py3.8 job seems to be failing for all PRs, unrelated to the changes provided here.

@filbranden
Copy link

Looks awesome! Would be nice if this was merged, I run into issues having to cast this every time I use it

Copy link
Contributor

@adehad adehad 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

search_issues can return either a dictionary (if json_result) or a list
of Issues under default behavior. This change provides separate hints
using overload so that type checked code doesn't need to cast
unnecessarily when dealing with output.
We now require json_result and use_post are passed as keyword arguments,
satisfying type checker requirements and handling the default return
value correctly.
As the correct type hint is now provided, this is no longer necessary.
@adehad adehad requested a review from a team as a code owner September 2, 2024 13:10
@adehad adehad requested a review from ssbarnea September 2, 2024 13:10
@adehad adehad enabled auto-merge (squash) September 2, 2024 13:10
@adehad adehad merged commit 9900396 into pycontribs:main Sep 2, 2024
15 checks passed
@Stealthii
Copy link
Contributor Author

Thank you for getting this merged!

@Stealthii Stealthii deleted the feature/overload-typehint branch September 3, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants