Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition rules from rules_python does not run mypy #77

Open
jumbosushi opened this issue Mar 23, 2023 · 0 comments
Open

Transition rules from rules_python does not run mypy #77

jumbosushi opened this issue Mar 23, 2023 · 0 comments

Comments

@jumbosushi
Copy link

jumbosushi commented Mar 23, 2023

🐞 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant