-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Only typecheck immediate sources, not transitive #12
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing this looks right. My single
--package-root
looks hacky and wrong, but it wasn't breaking things from what I can see. Did you encounter problems with--package-root .
?Why not also transitive
srcs
as--package-roots
too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing.
I encountered the package root issue trying to depend on the Google protobuf python target using @com_google_protobuf//:protobuf_python (similar to #11). However, after fixing the source roots, I found another issue: that target includes __init__.py's under compatibility_test/v2.5.0, which is not a valid Python module name, and since the mypy invocation includes all transitive sources, mypy fails on the bad module name. I ended up switching to depending on PyPI's protobuf, since that's packaged correctly (I think @com_google_protobuf//:protobuf_python is broken, in this case).
Now, after switching to protobuf from PyPI, I have a new issue: MYPYPATH isn't populated with imports from transitive dependencies. This causes mypy to emit tons of type errors for the protobuf library because mypy sees a different import path for the external dependency (something like
external.pypi__...__protobuf.google.protobuf
), so it fails to match it with typeshed's definitions. I haven't figured out how to fix this yet—let me know if you see an obvious solution.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like more of a mypy issue? The default
mypi.ini
is rather aggressive, if you turn off imports usingYou might see a solution to your problem. A less shotgun approach is to use
# type: ignore
. I just took a look at my code, which works with #11 and I have:In my mypy_test files.
Sorry I haven't taken the time to review this. I've been just using the tests not the aspect, so unless you make those changes- I don't have much to input.
But I'd be excited for a canonical solution that supports protobuf 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this also work as an alternative to
follow_imports=skip
?