youtype / mypy_boto3_builder

Type annotations builder for boto3 compatible with VSCode, PyCharm, Emacs, Sublime Text, pyright and mypy.
https://youtype.github.io/mypy_boto3_builder/
MIT License
544 stars 36 forks source link

[sts] GetCallerIdentityResponseTypeDef -> Arn should be 'str' but ist dict[str, Any] #222

Closed Wurstnase closed 1 year ago

Wurstnase commented 1 year ago

Describe the bug With mypy-boto3-sts==1.28.36 the return value for the ARN changed.

GetCallerIdentityResponseTypeDef -> Arn should be 'str' but ist dict[str, Any]

To Reproduce pip install -U 'mypy-boto3-sts==1.28.36'

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

sts_client = boto3.client("sts")
arn = sts_client..get_caller_identity()["Arn"]
reveal_type(arn)
...

Actual output

note: Revealed type is "builtins.dict[builtins.str, Any]"

Expected output

note: Revealed type is "builtins.str"

Additional context With mypy-boto3-sts==1.28.16 you will see the expected output.

vemel commented 1 year ago

Thank you for the report.

I think it is related to JSON string conversion in botocore. I will try to fix it today.

vemel commented 1 year ago

So, it looks like only strings with a particular pattern should be handled as a potential JSON. I left only two patterns that are converted to JSON: "[\\u0009\\u000A\\u000D\\u0020-\\u00FF]+" and "^[\\u0009\\u000A\\u000D\\u0020-\\u00FF]+$". All others are still considered strings.

@Wurstnase I published mypy-boto3-sts 1.28.36.post1 with the fix. Please update and let me know if it works for you. If it does - I release updates for all affected packages.

Wurstnase commented 1 year ago

Thanks. Looks good to me.