Transition rules from rules_python does not run mypy
Opened this issue ยท 0 comments
jumbosushi commented
๐ bug report
The following code in _mypy_aspect_impl
does not include the _transition_py_test
and _transition_py_binary
rules from rules_python (code). As a result, mypy did not run for targets that use py_test
from @python//<version>:def.bzl
bazel-mypy-integration/mypy.bzl
Lines 191 to 194 in 863fde2
As a workaround, I created applied a patch in my WORKSPACE and it seem to work:
def _mypy_aspect_impl(_, ctx):
if (ctx.rule.kind not in ["py_binary", "py_library", "py_test", "mypy_test", "_transition_py_test", "_transition_py_binary"] or
ctx.label.workspace_root.startswith("external")):
return []
Versions
- Bazel:
bazel 6.1.1
- rules_python:
0.18.1
- baze-mypy-integration:
c82a2d522d9e8e96ec30c4ab14a8066a09f7483e
(> 0.4.0)
How to reproduce
Demo workspace (clone of rules_python examples)
Run:
bazel test //tests:\* --aspects @mypy_integration//:mypy.bzl%mypy_aspect --output_groups=mypy
It should produce an error:
tests/version.py:18: error: Incompatible return value type (got "str", expected "int")
The error goes away once patch
line is removed in WORKSPACE