Simplify stubs management without types.requirements()#89
Open
brandonchinn178 wants to merge 4 commits intobazel-contrib:mainfrom
Open
Simplify stubs management without types.requirements()#89brandonchinn178 wants to merge 4 commits intobazel-contrib:mainfrom
brandonchinn178 wants to merge 4 commits intobazel-contrib:mainfrom
Conversation
66a0d3f to
f0c0e60
Compare
a06fcee to
11d590d
Compare
Draft
11d590d to
2e1a846
Compare
2e1a846 to
60739e5
Compare
Contributor
Author
|
Not sure why CI is failing: |
350fdd0 to
7837651
Compare
Contributor
Author
|
@apalmer-theorem Thoughts on this PR? |
7837651 to
f6fd4f7
Compare
This was referenced Aug 13, 2025
Collaborator
|
Sorry for the delay here, aiming to review in the next week or so. |
|
|
||
| return stubs | ||
|
|
||
| def load_stubs(requirements = [], overrides = {}): |
There was a problem hiding this comment.
I think it would be helpful if an override value could be a list of stubs. For some reason aiobotocore has several stub packages:
types-aiobotocorewhich has several extras, e.g.types-aiobotocore[dynamodb,s3,sqs]- and also individual packages:
I believe since rules_mypy doesn't understand extras, one would need to be able to specify something like:
overrides = {
requirement("aiobotocore"): [
requirement("types_aiobotocore_dynamodb"),
requirement("types_aiobotocore_s3"),
requirement("types_aiobotocore_sqs"),
],
},|
It seems that type packages don't get included transitively. where |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #86
The current implementation has a few limitations:
types-boto3[all]grpc-stubs<->grpcio)This PR makes the following changes:
py_type_libraryaltogether and put the types libraries in PYTHONPATH instead of MYPYPATHpy_type_libraryis to remove the-stubssuffix because MYPYPATH requires the name to be exact. But mypy already has logic to ignore the-stubssuffix if it's on PYTHONPATH ("installed in the current Python environment"), so we should just use thattypes.requirements()inMODULE.bazelwithload_stubs()helper inaspects.bzlload_stubs()takes in theall_requirementsoutput from@pip//:requirements.bzl, which contains the requirements that rules_python already parsedload_stubs()makes it clear thatrequirementsis just an automatic detection, but there's also anoverridesmechanism for manually specifying the mapping (i.e.requirementsis just a shortcut for manually specifyingoverridesfor everything)