Skip to content

[🐛 Bug]: [py] Many type annotation errors need fixing #15697

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

Open
cgoldberg opened this issue May 4, 2025 · 7 comments
Open

[🐛 Bug]: [py] Many type annotation errors need fixing #15697

cgoldberg opened this issue May 4, 2025 · 7 comments
Labels
C-py Python Bindings good first issue Good first issue for new contributors to start with I-defect Something is not working as intended R-help wanted Issues looking for contributions

Comments

@cgoldberg
Copy link
Contributor

cgoldberg commented May 4, 2025

Description

TLDR: Our use of type hints in the Python bindings needs some serious love.


Static typing is optional in Python, and we make use of it in many places throughout the Python bindings code. Static typing is not enforced at runtime, but can be checked with tooling like Mypy.

We currently have a Mypy environment and set of type checking rules declared in our tox.ini configuration. You can run Mypy locally with:

tox -e py/tox.ini -e mypy

Running this produces a screen full of type errors and:

Found 120 errors in 30 files (checked 114 source files)

We currently run Mypy in a CI workflow, but we don't display the errors or fail the job when it hits errors, so they just go unnoticed.

To resolve this issue, we should:

  • go through the codebase and fix all of the errors that Mypy finds
  • update the CI job to fail when Mypy encounters errors to enforce no future regressions

Reproducible Code

tox -e py/tox.ini -e mypy

Debugging Logs

Found 120 errors in 30 files (checked 114 source files)
@cgoldberg cgoldberg added the I-defect Something is not working as intended label May 4, 2025
@github-actions github-actions bot added C-py Python Bindings OS-linux labels May 4, 2025
@cgoldberg cgoldberg added R-help wanted Issues looking for contributions good first issue Good first issue for new contributors to start with labels May 4, 2025
@selenium-ci
Copy link
Member

This issue is looking for contributors.

Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested.

@MohabASHRAF-byte
Copy link

Hello, can I work on this ?

@navin772
Copy link
Member

navin772 commented May 5, 2025

@MohabASHRAF-byte yes, go ahead. We appreciate contributions from your side.

@MohabASHRAF-byte
Copy link

@navin772 Is there a communication channel other than GitHub?

@navin772
Copy link
Member

navin772 commented May 5, 2025

@MohabASHRAF-byte Yes, we use slack, you can join here - https://inviter.co/seleniumhq

@cgoldberg
Copy link
Contributor Author

@MohabASHRAF-byte thanks! Not only are there many Mypy errors, but many of the type annotations are using outdated classes and syntax. An easy way to update them is by using this:

https://github.com/asottile/pyupgrade

Run it across the whole codebase using Python 3.9 syntax.

Ping me here or on Slack if you have any questions.

@MohabASHRAF-byte
Copy link

@MohabASHRAF-byte thanks! Not only are there many Mypy errors, but many of the type annotations are using outdated classes and syntax. An easy way to update them is by using this:

https://github.com/asottile/pyupgrade

Run it across the whole codebase using Python 3.9 syntax.

Ping me here or on Slack if you have any questions.

ok, thank you, I will consider it, and I sent a request to join Slack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-py Python Bindings good first issue Good first issue for new contributors to start with I-defect Something is not working as intended R-help wanted Issues looking for contributions
Projects
None yet
Development

No branches or pull requests

4 participants