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

Aperta
#18,435 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
68/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
ci-cd, testing-qa

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
34.6k
Fork
8.7k
Merge medio
1g 16h
PR unite (30g)
107

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SeleniumHQ/selenium

Tutte le issue di SeleniumHQ/selenium

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.