youtype/mypy_boto3_builder

`Stubber.__exit__` has incorrect type

Closed this issue · 3 comments

tibbe commented

Describe the bug
Similar to #185 Stubber.__exit__ is missing type annotations and is thus not compatible with e.g. contextlib.ExitStack.enter_context. Fix will be similar to a26cf63 but for Stubber.

To Reproduce
Steps to reproduce the behavior:

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

import boto3

with contextlib.ExitStack() as stack:
    dynamodb_stub = stack.enter_context(Stubber(boto3.client("dynamodb")))

Actual output

Argument 1 to "enter_context" of "ExitStack" has incompatible type "Stubber"; expected "AbstractContextManager[<nothing>]"

Expected output

No type error.

Additional context
Your OS, boto3-stubs installation method, boto3 version, etc.

tibbe commented

It's not entirely clear to me if this type annotation should live in this project or botocore. I filed boto/botocore#2873 against botocore.

vemel commented

Thank you for the report!

Fixed in botocore-stubs 1.29.93.post1. Please test this new release and let me know if it works as expected.

tibbe commented

Works!