Skip to content

How to add stubs #86

@brandonchinn178

Description

@brandonchinn178

In bazel-mypy-integration, you were able to specify mypy_stub targets to add stubs for third party libraries that dont have type hints. Now that bazel-mypy-integration is deprecated in favor of rules_mypy, how would we do the same here?


EDIT: I now see py_library has pyi_srcs, so I could add stubs as a normal py_library target. However, it seems like the third party dep appears in MYPYPATH before py_library deps, so the third party dep is found first.

I have a temporary workaround where I do

stubs = {
    requirement("foo"): "@@//stubs:foo",
}

mypy_aspect = mypy(
    types = types | stubs,
)

which seems to work, but seems hacky

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