[py] Fix: Mypy type annotation errors - 5 #15908
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User description
🔗 Related Issues
#15697
💥 What does this PR do?
This PR fixes type annotation issues in the following files:
py/selenium/webdriver/support/event_firing_webdriver.pypy/selenium/webdriver/webkitgtk/service.pypy/selenium/webdriver/wpewebkit/service.py🔧 Implementation Notes
Uses
getattr/setattrfor safer attribute manipulation and fixes type annotations to match actualshutil.which()return type.💡 Additional Considerations
🔄 Types of changes
PR Type
Bug fix
Description
• Fix MyPy type annotation errors in WebDriver support and service modules
• Update
shutil.which()return type annotations toOptional[str]• Improve attribute manipulation safety using
getattr/setattr• Fix log file handling in WebKit service constructors
Changes walkthrough 📝
event_firing_webdriver.py
Improve attribute manipulation safetypy/selenium/webdriver/support/event_firing_webdriver.py
• Replace direct attribute assignment with safer
getattr/setattrpattern
• Store original
_wrap_valueattribute before modificationservice.py
Fix type annotations and log handlingpy/selenium/webdriver/webkitgtk/service.py
• Change
DEFAULT_EXECUTABLE_PATHtype annotation toOptional[str]•
Update constructor parameter type to match
shutil.which()return type• Fix log file handling with proper variable naming
service.py
Fix executable path type annotationpy/selenium/webdriver/wpewebkit/service.py
• Update constructor parameter type annotation to
Optional[str]•
Match
shutil.which()return type for executable path