Hello @swetashre,
I added boto3-stubs that was auto-generated from boto3 source code. Is it okay to keep it public?
It is recognized by mypy as an interface module for boto3.
Regards
Any update?
@vemel - Sorry for the late reply. boto3-stubs is not maintained by AWS. So i don't know much about it.
We have a working implementation of of boto3 type stubs for the same purpose and its located here: https://github.com/boto/botostubs. Its not production ready yet but you can see our approach at least and how it should work. It still needs some work and tests.
Thank you for your response!
boto3-stubs is maintained by me now.
More or less the idea is the same - I parse botocore shapes to build argument and return type annotations and I also use inspect with docstring parsing to annotate dynamic methods added by boto3 - this part is missing in botogen as I see.
What these projects have in common:
botocore shapesblack for readabilityMain differences from botogen:
TypedDict argument and return types with proper required and optional fieldsTypedDict annotations support (required for dynamodb service)Literal argument type annotations for IDE auto-complete and type checkingboto.client(...).Exceptions structure for IDE auto-complete and type checkingboto3boto3 (used in s3 and ec2 service and probably some others). botocore shapes are changed by boto3 sometimes, so shapes give you incorrect method signatures.boto3.client and boto3.resource function overloads - basically I generate overloads only for services you have installed. Creating overloads for all services easily kills mypy and PyCharm due to high RAM usage.botogen is missing 3.6 supportboto3 versions and upload to PyPI, so end user can install them with pip or poetry for his boto3 versionI would like to help the project as my implementation works and covers all boto3 services and boto3. botocore stubs are not included, it was not one of my goals.
Let me know if you need any additional info about the project, because I guess it might be useful.
Regards, Vlad.
Sorry for pinging you again, @swetashre . Please let me know if there are any updates.
I'm joining the question... What's the status with this?
Still, no updates for https://github.com/boto/botostubs , while boto3-stubs is production-ready.
@swetashre let me know if we can somehow make boto3-stubs officially supported. There are few things that can be improved with the help of boto3 team:
None is not handled the same as not passing argument at all, see https://github.com/boto/botocore/issues/2075s3 service)__init__.py and session.py can be merged to boto3 source code. I annotated all boto3 modules but probably missing some attribute annotations.boto3 can even add keyword arguments from shapes to methods instead of hiding them behind *args, **kwargs, this would make boto3 more user-friendly.Some additional features could be to provide typing-friendly methods to avoid overloading literals which are not currently supported correctly by any IDE. To avoid breaking changes, old methods should still exist but return botocore types
s3_client = boto3.s3_client(...) # new: returns S3Client
s3_client = boto3.client("s3", ...) # old: returns botocore.BaseClient
s3_resource = boto3.s3_resource(...) # new: returns S3ServiceResource
s3_resource = boto3.resource("s3", ...) # old: returns botocore.ServiceResource
s3_client.get_bucket_exists_waiter() # new: returns BucketExistsWaiter
s3_client.get_waiter("bucket_exists") # old: returns botocore.Waiter
Regards, Vlad.
Hey @swetashre - any updates on this issue? Radio silence for a period of almost one year is a bit concerning.
Most helpful comment
Thank you for your response!
boto3-stubsis maintained by me now.More or less the idea is the same - I parse
botocoreshapes to build argument and return type annotations and I also useinspectwith docstring parsing to annotate dynamic methods added byboto3- this part is missing inbotogenas I see.What these projects have in common:
botocoreshapesblackfor readabilityMain differences from
botogen:TypedDictargument and return types with proper required and optional fieldsTypedDictannotations support (required fordynamodbservice)Literalargument type annotations for IDE auto-complete and type checkingboto.client(...).Exceptionsstructure for IDE auto-complete and type checkingboto3boto3(used ins3andec2service and probably some others).botocoreshapes are changed byboto3sometimes, so shapes give you incorrect method signatures.boto3.clientandboto3.resourcefunction overloads - basically I generate overloads only for services you have installed. Creating overloads for all services easily killsmypyandPyCharmdue to high RAM usage.botogenis missing 3.6 supportboto3versions and upload to PyPI, so end user can install them withpiporpoetryfor hisboto3versionI would like to help the project as my implementation works and covers all
boto3services andboto3.botocorestubs are not included, it was not one of my goals.Let me know if you need any additional info about the project, because I guess it might be useful.
Regards, Vlad.