[py] integrate mypy type checking with Bazel#16958
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This PR migrates mypy type checking from tox to Bazel, consolidating Python tooling into the standard build system. The change adds mypy as a direct dependency, creates a Bazel-compatible wrapper script, and updates CI workflows.
Changes:
- Added
mypy==1.19.1dependency with lockfile updates including new transitive dependencies (librt,pathspec) - Created
run_mypy.pyscript that uses mypy's Python API for Bazel sandbox compatibility - Updated CI workflow to use
bazel run //py:mypyinstead of tox-based type checking - Integrated mypy into the
all:lintRakefile task
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| py/run_mypy.py | New script using mypy API for Bazel integration with workspace directory detection |
| py/BUILD.bazel | Added py_binary target for mypy with selenium package and pyproject.toml as dependencies |
| py/requirements.txt | Added mypy==1.19.1 dependency |
| py/requirements_lock.txt | Updated lockfile with mypy and transitive dependencies (librt, pathspec), modified dependency comments |
| .github/workflows/ci-python.yml | Replaced tox-based type checking with Bazel workflow integration |
| Rakefile | Added mypy execution to the all:lint task |
cgoldberg
left a comment
There was a problem hiding this comment.
LGTM 👍
I just pushed a small update to your branch that removes the typecheck dependency group. We no longer need it if mypy is part of requirements.txt.
|
I also set the executable permission on the new |
User description
💥 What does this PR do?
Replaces tox-based mypy type checking with a Bazel target, integrating Python type checking into the standard build system.
mypy==1.19.1topy/requirements.txtand updated the lockfile//py:mypyBazel target usingpy_binarythat imports mypy's API directlybazel run //py:mypyinstead of toxall:lintRakefile task🔧 Implementation Notes
The
run_mypy.pyscript uses mypy's Python API rather than subprocess to ensure it works correctly within Bazel's sandbox environment.Configuration is read from the existing
[tool.mypy]section inpy/pyproject.toml.💡 Additional Considerations
Is there anything else tox related to bazelfy?
🔄 Types of changes
PR Type
Enhancement, Tests
Description
Integrate mypy type checking into Bazel build system
Replace tox-based type checking with
bazel run //py:mypyAdd mypy==1.19.1 dependency and update lockfile
Update CI workflow and Rakefile lint task
Diagram Walkthrough
File Walkthrough
run_mypy.py
New mypy wrapper script for Bazelpy/run_mypy.py
environment variable
BUILD.bazel
Add mypy Bazel targetpy/BUILD.bazel
py_binarytarget named "mypy"ci-python.yml
Update CI workflow for Bazel mypy.github/workflows/ci-python.yml
bazel run //py:mypycommandRakefile
Add mypy to Rakefile lint taskRakefile
Bazel.execute('run', [], '//py:mypy')to all:lint taskrequirements.txt
Add mypy dependencypy/requirements.txt
mypy_extensions
requirements_lock.txt
Update lockfile with mypy dependenciespy/requirements_lock.txt