Git Product home page Git Product logo

Comments (6)

stevenjackson121 avatar stevenjackson121 commented on May 23, 2024

On a related note:

import boto3
from mypy_boto3_s3 import S3ServiceResource
from mypy_boto3_s3.service_resource import Bucket

service_resource: S3ServiceResource = boto3.resource("s3")

buckets = service_resource.buckets.pages()

for bucket in buckets:
    for m in bucket.multipart_uploads:
        reveal_type(m)
    for object in bucket.objects:
        reveal_type(object)
    reveal_type(bucket)

gives the following mypy output:

s3_service_resource.py:11: note: Revealed type is 'Any'
s3_service_resource.py:13: note: Revealed type is 'Any'
s3_service_resource.py:14: note: Revealed type is 'mypy_boto3_s3.service_resource.Bucket*'

Expected mypy output is

s3_service_resource.py:11: note: Revealed type is 'mypy_boto3_s3.service_resource.MultiPartUpload'
s3_service_resource.py:13: note: Revealed type is 'mypy_boto3_s3.service_resource.Object'
s3_service_resource.py:14: note: Revealed type is 'mypy_boto3_s3.service_resource.Bucket*'

from mypy_boto3_builder.

stevenjackson121 avatar stevenjackson121 commented on May 23, 2024

An entirely separate issue (I can create it separately if you like, but for DynamoDB you recommended collecting issues on the same Service in one Github Issue):

Describe the bug
mypy_boto3_s3.S3ServiceResource.MultipartUpload should support Part() (it should return a mypy_boto3_s3.S3ServiceResource.MultipartUploadPart, and is the only way to create these AFAIK

To Reproduce
Steps to reproduce the behavior:

  1. Install 'boto3-stubs[s3]'
  2. Run mypy on the following code sample
import boto3
from mypy_boto3_s3 import S3ServiceResource
from mypy_boto3_s3.service_resource import Bucket

service_resource: S3ServiceResource = boto3.resource("s3")

multipart_upload = service_resource.MultipartUpload("foo", "bar", "baz")
multipart_upload_part = multipart_upload.Part("1")
multipart_upload.abort()
  1. Actual mypy output
s3_service_resource.py:8: error: "MultipartUpload" has no attribute "Part"
Found 1 error in 1 file (checked 1 source file)

Expected mypy-output

No Errors (checked 1 source file)

Additional context
Mac OS, pipenv installation, boto3 version 1.12.12, etc.

from mypy_boto3_builder.

vemel avatar vemel commented on May 23, 2024

Looks like collection-related types are incorrect. It is a bit hard to parse them from botocore shapes, so there are some hardcoded methods. Thank you for your report, I will update e2e tests and try to fix collections.

from mypy_boto3_builder.

vemel avatar vemel commented on May 23, 2024

Fixes for first two issues are in master. Regarding the third one - looks like I am not adding sub-resources for collections https://boto3.amazonaws.com/v1/documentation/api/1.12.5/reference/services/s3.html#S3.MultipartUpload

from mypy_boto3_builder.

vemel avatar vemel commented on May 23, 2024

Fixed both issues in new release 1.0.4 . Please update boto3-stubs and boto3.

Let me know if it works as it should. Thank you!

from mypy_boto3_builder.

stevenjackson121 avatar stevenjackson121 commented on May 23, 2024

Everything works. Thanks for the very quick response + fix!

from mypy_boto3_builder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.