Skip to content

[py] chore fix for unreachable mypy warnings - #17969

Merged
iampopovich merged 4 commits into
SeleniumHQ:trunkfrom
iampopovich:chore/fix-python-warns-for-unreachable
Sep 2, 2026
Merged

[py] chore fix for unreachable mypy warnings#17969
iampopovich merged 4 commits into
SeleniumHQ:trunkfrom
iampopovich:chore/fix-python-warns-for-unreachable

Conversation

@iampopovich

Copy link
Copy Markdown
Contributor

🔗 Related Issues

💥 What does this PR do?

PR fixes warnings for mypy checks


➜  selenium git:(trunk) ✗ bazel run //py:mypy
INFO: Analyzed target //py:mypy (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //py:mypy up-to-date:
  bazel-bin/py/mypy
INFO: Elapsed time: 0.456s, Critical Path: 0.07s
INFO: 2 processes: 2 internal.
INFO: Build completed successfully, 2 total actions
INFO: Running command line: bazel-bin/py/mypy
^Kselenium/webdriver/common/proxy.py:204: error: Statement is unreachable  [unreachable]
selenium/webdriver/common/proxy.py:209: error: Statement is unreachable  [unreachable]
selenium/webdriver/firefox/options.py:31: error: Statement is unreachable  [unreachable]
selenium/webdriver/common/service.py:159: error: Right operand of "and" is never evaluated  [unreachable]
selenium/webdriver/common/service.py:160: error: Statement is unreachable  [unreachable]
selenium/webdriver/common/actions/pointer_input.py:49: error: Statement is unreachable  [unreachable]
pyproject.toml: note: unused section(s): module = ['selenium.webdriver.common.devtools.*']
Found 6 errors in 4 files (checked 104 source files)

🔧 Implementation Notes

🤖 AI assistance

  • No substantial AI assistance used
  • AI assisted (complete below)
    • Tool(s): Claude Sonnet 5 with medium effort
    • What was generated: types annotations
    • I reviewed all AI output and can explain the change

💡 Additional Considerations

🔄 Types of changes

  • Cleanup (formatting, renaming)

Copilot AI lite review requested due to automatic review settings August 28, 2026 22:48
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 tightens Python typing annotations and updates the Python mypy configuration to eliminate “unreachable” warnings, aligning the bindings with stricter static analysis while keeping runtime behavior effectively unchanged.

Changes:

  • Enable warn_unreachable in py/pyproject.toml and remove an unused mypy override entry.
  • Add/adjust type annotations in several Python binding modules to make previously “unreachable” branches type-reachable (e.g., Proxy.noProxy, Proxy.socksVersion, pointer move origin, Firefox Log.level).
  • Simplify Service.stop() log handle closing logic to avoid mypy “unreachable” diagnostics while preserving ownership-based closing behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
py/selenium/webdriver/firefox/options.py Annotates Log.level as `str
py/selenium/webdriver/common/service.py Adjusts log output closing logic to avoid mypy unreachable analysis while keeping owned-resource cleanup.
py/selenium/webdriver/common/proxy.py Annotates proxy fields (noProxy, socksVersion, etc.) so BiDi conversion branches are type-reachable.
py/selenium/webdriver/common/actions/pointer_input.py Widens origin to `WebElement
py/pyproject.toml Enables unreachable warnings and removes an unused mypy override section.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@iampopovich
iampopovich requested a review from cgoldberg August 28, 2026 23:02
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@iampopovich
iampopovich merged commit 483f8cd into SeleniumHQ:trunk Sep 2, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-py Python Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants