youtype/mypy_boto3_builder

`s3.Object.copy_from` is missing dict type for `CopySource` parameter

Closed this issue · 4 comments

Describe the bug
In boto3 docs the s3.Object.copy_from supports a union of string and dict:

    CopySource='string' or {'Bucket': 'string', 'Key': 'string', 'VersionId': 'string'},

However in the latest type stub (mypy-boto3-s3 1.34.138) there's only str:

        CopySource: str,

To Reproduce
Steps to reproduce the behavior:

  1. Install boto3-stubs[essential]
  2. Run mypy/pyright on the following code sample
import boto3

boto3.resource('s3').Object('foo', 'bar').copy_from(CopySource={'Bucket': 'bar', 'Key': 'foo'})

Actual output

test.py
  test.py:3:64 - error: Argument of type "dict[str, str]" cannot be assigned to parameter "CopySource" of type "str" in function "copy_from" (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations

Expected output

0 errors, 0 warnings, 0 informations

Additional context
Very similar issue as #169

Hello! Thank you for the report.

Looks like CopySource argumet type annotation is incorrect for Object.copy_from and ObjectSummary.copy_from.

Fixed in the latest mypy_boto3_builder 7.15.3 verison. Also, I released mypy-boto3-s3 1.34.158 with the fix included. Please update and let me know if it works as it should.

works! this was the change? 8ea2150

and thanks!

Yes. As you see, I was overriding copy/copy_from for multiple resources already, but Object and ObjectSummary were not covered.