This repository was archived by the owner on May 8, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 44
mypy_stubs issuesΒ #146
Copy link
Copy link
Open
Description
I'm encountering a few issues with mypy_stubs:
-
Stubs included transitively aren't being included:
mypy_stubs(name = "kafka_stub", srcs = ["kafka.pyi"]) py_library(name = "dep", srcs = ["dep.py"], deps = [":kafka_stub"]) py_binary(name = "main", srcs = ["main.py"], deps = [":dep"])
With this setup, building
mainfails becausedep.pyis included in the mypy invocation, butkafka.pyiisn't transitively included instub_files, which meanskafka.pyiisn't making it intomypypath -
A tree of stub files isn't included in the mypy path correctly. Currently, the integration only adds the mypy_stubs' files' immediate directory into MYPYPATH, but that won't resolve nested structures like
a/__init__.pyanda/b/__init__.py- I also suspect that having
a/__init__.pyandb/__init__.pywould also error currently
- I also suspect that having
Current workaround
I'm currently adding a patch file doing the equivalent of the following:
# transitively include stubs
for deps in transitive_srcs_depsets:
for f in deps.to_list():
if f.extension == "pyi":
stub_files.append(f)
# only add stub root
mypypath_parts += [src_f.dirname for src_f in stub_files if src_f.basename == "__stubs_root__.pyi"]and then adding __stubs_root__.pyi to every mypy_stubs target
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels