Failing to resolve source code imports
cwaeland opened this issue · 2 comments
First, thanks for working on this integration. I'm excited to incorporate it into our Python 3 code base.
With some of my initial tests I'm seeing numerous errors of the type Cannot find implementation or library stub for module named ...
. I suspect the issue is our use of the imports
attribute on a shared py_library
rule.
Our code is structured such that we have a src/python3
directory in our repository which our imports are relative to.
The majority of our packages live under a subdirectory called uc
so most of our imports start with uc.
. We have a py_library rule that everything depends on directly or transitively that has imports = [".."]
. This works well for us with Bazel so far but I'm wondering if it's what is causing the issue.
I noticed that you had #8 which looks at imports for py_test
and py_binary
so I'm wondering if it's the combination of py_library
and ..
that isn't handled.
Any ideas? Thanks!
So I ended up playing around with grabbing the imports
from the transitive dependencies and that seems to have resolved the issue with my uc.*
packages. However, I'm still seeing some issues unfortunately.
- It doesn't seem to like my generated source files. We're currently generating Python source from Thrift using a custom rule that we wrote which generates
py_library
targets withimports
. SeeingCannot find implementation or library stub for module named
in this instance. I've tried adding updating the mypy_path here as well to no avail. - Additionally it's also complaining about the third party imports. Here we're seeing
Cannot find implementation or library stub for module named 'thrift.protocol'
for example. We are usingrules_pip
to download dependencies but I believe it does it similarly to howrules_python
does it. We don't have stub files either but it looks like the source of the modules is there.
Thanks. I'm sure I'm missing something silly.
Hey, regarding 1.
that's certainly a big pain point with this implementation. I've only had initial success with generated python code that came from:
http_archive(
name = "build_stack_rules_proto",
urls = ["https://github.com/stackb/rules_proto/archive/{version}.tar.gz".format(version = rules_proto_version)],
sha256 = "d456a22a6a8d577499440e8408fc64396486291b570963f7b157f775be11823e",
strip_prefix = "rules_proto-{version}".format(version = rules_proto_version),
)
Regarding 2.
have you adding entries like this to your mypy.ini
?
[mypy-atlassian.*]
ignore_missing_imports = True
[mypy-avro.*]
ignore_missing_imports = True