botostubs icon indicating copy to clipboard operation
botostubs copied to clipboard

Undefined methods not detected due to BaseClient

Open jamesls opened this issue 3 years ago • 0 comments

This type checks even though I would expect it to fail:

$ cat app.py
from typing import List

import botocore.session


def testit() -> List[str]:
    session = botocore.session.Session()
    client = session.create_client('s3')
    response = client.unknown_method()
    reveal_type(response)
    return [b['Name'] for b in response['Buckets']]


testit()
$ mypy app.py
Success: no issues found in 1 source file

The reveal_type is Any which explains why it type checks.

However, if I remove the BaseClient subclass in the stub definitions, then I get the error I expect:


-class S3(BaseClient):
+class S3:
     def abort_multipart_upload(self, *,
         Bucket: str,
         Key: str,
...

$ mypy app.py
app.py:9: error: "S3" has no attribute "unknown_method"
Found 1 error in 1 file (checked 1 source file)

jamesls avatar Aug 27 '20 18:08 jamesls