-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[py] Fix return type hint for alert_is_present
#16975
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
|
Thank you, @nemowang2003 for this code suggestion. The support packages contain example code that many users find helpful, but they do not necessarily represent After reviewing the change, unless it is a critical fix or a feature that is needed for Selenium We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks. |
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||||||
PR Code Suggestions ✨No code suggestions found for the PR. |
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.
Pull request overview
This PR fixes a type hint issue in the Python bindings' expected conditions module. The return type of alert_is_present() is changed from Alert | bool to Alert | Literal[False] to enable proper static type inference when used with WebDriverWait.until().
Changes:
- Updated the return type annotation for
alert_is_present()fromAlert | booltoAlert | Literal[False]
cgoldberg
left a comment
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... good catch.
I just updated your branch so the docstring matches the return type.
--------- Co-authored-by: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com>
--------- Co-authored-by: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com>
User description
[py] Fix return type hint for
alert_is_present🔗 Related Issues
💥 What does this PR do?
Updates the return type hint for
expected_conditions.alert_is_present.Previously,
alert_is_presentwas typed as returningAlert | bool.This union type prevented static type checkers from correctly inferring the return type asAlertwhen the method is successfully used insideWebDriverWait.until().🔧 Implementation Notes
💡 Additional Considerations
🔄 Types of changes
PR Type
Bug fix
Description
Fix return type hint for
alert_is_presentfromAlert | booltoAlert | Literal[False]Enables static type checkers to correctly infer
Alertreturn type inWebDriverWait.until()Improves type safety and IDE autocompletion for alert handling
Diagram Walkthrough
File Walkthrough
expected_conditions.py
Update alert_is_present return type annotationpy/selenium/webdriver/support/expected_conditions.py
alert_is_present()fromCallable[[WebDriver], Alert | bool]toCallable[[WebDriver], Alert |Literal[False]]Literal[False]instead ofgeneric
boolfor the failure caseAlertwhen used withWebDriverWait.until()