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

Add imports from current target to MYPYPATH #39

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/demo/standalone_imports/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
py_library(
name = "foo",
srcs = glob(["*.py"]),
imports = ["."],
)
2 changes: 2 additions & 0 deletions examples/demo/standalone_imports/a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def foo():
pass
1 change: 1 addition & 0 deletions examples/demo/standalone_imports/b.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from a import foo
3 changes: 3 additions & 0 deletions mypy/private/mypy.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def _mypy_impl(target, ctx):
if dep.label in type_mapping
]

if PyInfo in target:
custom_imports.extend([x.split("/", 1)[-1] for x in target[PyInfo].imports.to_list()])

for dep in (ctx.rule.attr.deps + additional_types):
depsets.append(dep.default_runfiles.files)

Expand Down