[šŸš€ Feature]: Lint and type-check the Python BiDi modules generated at build time

Open
#18,435 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
68/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
ci-cd, testing-qa

Research direction

Start with py/generate_bidi_protocol.py, py/private/generate_bidi_protocol.bzl, and the py:lint entry point to see how Bazel builds the generated modules and how lint currently runs. Then check the py/pyproject.toml exclusions and the generated errors.py, emulation.py, and common._bidi outputs. Done means the Bazel-built outputs pass ruff check, ruff format --check, and mypy in the lint workflow, with the existing generator output errors fixed.

Written by the indexing model from the issue text.

Description

B-build C-py I-enhancement
Description

The common._bidi domain modules generated by py/generate_bidi_protocol.py are never linted or type-checked, in CI or locally. ./go py:lint (the CI Lint job) runs ruff and mypy on the source tree, where those modules are gitignored and absent, and ruff's respect-gitignore = true skips them even after bazel run //py:generate-bidi-protocol writes them there.

While changing which collections.abc names the generator imports, I found that only a unit test of the generator's import logic would catch it emitting an annotation it doesn't import: the modules use from __future__ import annotations, so a missing import doesn't fail at import time either.

What the current output has (ruff 0.17.6):

  • 57 ruff errors: 50 RUF036 (None not last in a union), 6 E501 and 1 I001 in errors.py.
  • emulation.py and errors.py are not ruff format clean.
  • mypy passes when the modules are generated into the tree and //py:mypy is run locally.

The generator's module docstring says "the build applies a format pass", but py/private/generate_bidi_protocol.bzl runs only the generator.

Suggestion: add a check that runs ruff check, ruff format --check and mypy against the Bazel-built //py:create-bidi-protocol-src outputs and include it in ./go py:lint, after fixing the existing errors in the generator so it starts green. The older generated layers (common/bidi, common/devtools) are deliberately excluded from ruff in py/pyproject.toml and are out of scope.

Related: #18378 has the same root cause for the API docs (built from the source tree, so generated modules are never listed).

Have you considered any alternatives or workarounds?

Have ./go py:lint run //py:generate-bidi-protocol first and lint that directory with --no-respect-gitignore. That is smaller, but it checks the working tree rather than what Bazel builds and ships, which is the same gap #18378 describes for the docs.

Dominant language
Java
Stars
34.6k
Forks
8.7k
Avg merge
1d 16h
Merged PRs (30d)
107

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SeleniumHQ/selenium

All issues in SeleniumHQ/selenium

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.