Closed nint8835 closed 1 year ago
Thank you for this well-written bug report!
I fixed service_id: ServiceId
argument type. The fix is included in botocore-stubs 1.29.103.post1
. Please test it and let me know if it works as expected. Regarding PyCharm
issue - I will check if it works as well.
Tested and confirmed the mypy issue is resolved, thanks once again for the quick fix!
With regards to the PyCharm issue, I'm still running into it but a bit differently now - I'm getting
Expected type 'ServiceId | ServiceId', got '() -> ServiceId | CachedProperty' instead
When trying to pass session.client(...).meta.service_model.service_id
as the service_id
argument. My best guess is it's probably something on the go with the CachedProperty
decorator on the service_id in the service_model. I know PyCharm doesn't properly support some recent mypy features, that might be what's on the go there. I can open a separate issue for that problem if you want, I'm also content to just leave it as it is where it seems to be an editor-specific issue.
Follow-up issue to https://github.com/youtype/mypy_boto3_builder/issues/195 upon a bit of further testing, looks like I'm hitting an issue that's one part PyCharm issue, one part botocore-stubs issue.
In botocore's docstrings, it says that
RequestSigner
takes abotocore.model.ServiceId
, however in botocore-stubs, it says it takes astr
.Repro
pip install boto3-stubs[sts]
Expected result
invalid_signer
should either result in a mypy error, or should work when you callget_presigned_url
valid_signer
should either result in no mypy error, or should not work when you callget_presigned_url
Actual result
generate_presigned_url
oninvalid_signer
results in an attribute error due to attempting to accesshyphenize
onstr
, whereas it only exists onServiceId
, and does not result in a mypy errorgenerate_presigned_url
onvalid_signer
works, but gives a type error in PyCharm. This part is partially the PyCharm issue, as I'm pretty sure it's a false positive in PyCharm due to ServiceId that we're passing being a subclass ofstr
, so even with the current type annotations I believe this should be valid.