Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Transition rules from rules_python does not run mypyΒ #77

@jumbosushi

Description

@jumbosushi

🐞 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions