-
Notifications
You must be signed in to change notification settings - Fork 5
Simplify stubs management without types.requirements() #89
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
base: main
Are you sure you want to change the base?
Conversation
66a0d3f
to
f0c0e60
Compare
a06fcee
to
11d590d
Compare
11d590d
to
2e1a846
Compare
2e1a846
to
60739e5
Compare
Not sure why CI is failing:
|
350fdd0
to
7837651
Compare
@apalmer-theorem Thoughts on this PR? |
7837651
to
f6fd4f7
Compare
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-aiobotocore
which 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
|
Fixes #86
The current implementation has a few limitations:
types-boto3[all]
grpc-stubs
<->grpcio
)This PR makes the following changes:
py_type_library
altogether and put the types libraries in PYTHONPATH instead of MYPYPATHpy_type_library
is to remove the-stubs
suffix because MYPYPATH requires the name to be exact. But mypy already has logic to ignore the-stubs
suffix if it's on PYTHONPATH ("installed in the current Python environment"), so we should just use thattypes.requirements()
inMODULE.bazel
withload_stubs()
helper inaspects.bzl
load_stubs()
takes in theall_requirements
output from@pip//:requirements.bzl
, which contains the requirements that rules_python already parsedload_stubs()
makes it clear thatrequirements
is just an automatic detection, but there's also anoverrides
mechanism for manually specifying the mapping (i.e.requirements
is just a shortcut for manually specifyingoverrides
for everything)