Skip to content

Undefined methods not detected due to BaseClient #4

Open
@jamesls

Description

@jamesls

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions