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

Failing to resolve source code imports #23

Open
cwaeland opened this issue Oct 9, 2020 · 2 comments
Open

Failing to resolve source code imports #23

cwaeland opened this issue Oct 9, 2020 · 2 comments

Comments

@cwaeland
Copy link

cwaeland commented Oct 9, 2020

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!

@cwaeland
Copy link
Author

cwaeland commented Oct 9, 2020

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.

  1. 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 with imports. Seeing Cannot 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.
  2. 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 using rules_pip to download dependencies but I believe it does it similarly to how rules_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.

@thundergolfer
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants