-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Chore: Added type hints to searches/binary_search.py #2682
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
Chore: Added type hints to searches/binary_search.py #2682
Conversation
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.
LGTM.
@Panquesito7, I approve of these changes. Please look into it.
Sorry, I'm not a Python developer/maintainer. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hey @hemanth-kotagiri, how can we get this merged? It's becoming stale |
@UmairKamran, I do not have the rights for this repository yet to merge your PR. What I'd suggest you is the email or ping @cclauss for the same. Thanks! |
Closing and reopening this pull request to run checks done by the bot. |
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.
Sorry for the delay. Small changes and this is good to go!
searches/binary_search.py
Outdated
@@ -219,7 +228,7 @@ def binary_search(sorted_collection, item): | |||
return None | |||
|
|||
|
|||
def binary_search_std_lib(sorted_collection, item): | |||
def binary_search_std_lib(sorted_collection, item) -> Optional[int]: |
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.
I think you missed a few in here :)
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.
Good catch! Looks like @cclauss has taken care of this
I will fix it and land it in the next few hours. Instead of parameters that can be either int or None, it would be better if they were only int where we use -1 as the signal value rather than None. |
Ah, so you want to use the Sentinel pattern? There's a good article about it: https://python-patterns.guide/python/sentinel-object/ Any reason why you are preferring for an |
@dhruvmanila @cclauss Thank you for reviewing :) |
The expected datatype is int so why make things more complicated if we can find a suitable sentinel value of that datatype? The current project that I am working on overuses |
Describe your change:
Added missing type hints as described in this issue -> #2128
Checklist:
Fixes: #{$ISSUE_NO}
.