bazel-contrib/bazel-mypy-integration

Transition rules from rules_python does not run mypy

Opened this issue ยท 0 comments

๐Ÿž 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

def _mypy_aspect_impl(_, ctx):
if (ctx.rule.kind not in ["py_binary", "py_library", "py_test", "mypy_test"] or
ctx.label.workspace_root.startswith("external")):
return []

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

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