-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[py] Fix type annotation errors in service.py #16250
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
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Fixed the instance variable log_output by properly annotating it as int | IOBase | None. Removed unnecessary #type: ignore comments where mypy requires them.
4262d10
to
4f0434c
Compare
This is exactly the issue. We are using https://mypy.readthedocs.io/en/stable/common_issues.html#python-version-and-system-platform-checks I wonder if we should change our platform detection across the entire codebase to use I don't really care if we leave the comments in this PR (we're going to get an error on one platform or the other either way). I'll open a new issue to investigate switching to |
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! We can take care of windows error in the other issue created. Currently, mypy
on CI runs on Ubuntu so it should not raise any type errors.
User description
Fixed the instance variable log_output by properly annotating it as int | IOBase | None. Removed unnecessary #type: ignore comments where mypy requires them.
🔗 Related Issues
Partially addresses #15697
💥 What does this PR do?
Fixes mypy type annotation errors in
selenium/webdriver/common/service.py
:self.log_output
asint | IOBase | None
.cast()
only where mypy requires it, removed unnecessarycast()
.#type: ignore
comments.🔧 Implementation Notes
self.log_output
asOptional[Union[int, IOBase]]
.log_output
uses but that also includesstr
which the instance variable will never bestr
.cast()
onself.log_output = log_output
because parameterlog_output
is annotated withIO[Any]
instead ofIOBase
.💡 Additional Considerations
ruff check
🔄 Types of changes
PR Type
Other
Description
Fix type annotation errors in service.py
Remove unnecessary type ignore comments
Add proper type annotation for log_output instance variable
Clean up cast() usage where not needed
Diagram Walkthrough
File Walkthrough
service.py
Fix type annotations and remove unnecessary casts
py/selenium/webdriver/common/service.py
log_output
instance variablecast()
calls in conditional branches# type: ignore
comments for Windows subprocess attributescast()
where mypy requires it for type compatibility