botostubs icon indicating copy to clipboard operation
botostubs copied to clipboard

Not compatible with mypy

Open shadycuz opened this issue 3 years ago • 2 comments

Not sure the level of effort to get this to work with mypy. I have many examples but this one makes the most sense:

Making API call with filter:

response = client.describe_instance_type_offerings(
        LocationType=location,
        Filters=[{"Name": "instance-type", "Values": [instance_type]}],
    )

mypy error:

error: List item 0 has incompatible type "Dict[str, Sequence[str]]"; expected "Filter"  [list-item]

I have tried many ways to fix it:

filter: botostubs.EC2.Filter = {
        "Name": "instance-type",
        "Values": [instance_type]
    }

but nothing works. Thats because the variable filter is supposed to be an instance of the class Filter. Where really with boto3 a filter is a Dict[str, Any].

I haven't even looked at what it would take to implement but I might give this a look if this is something people are interested in.

shadycuz avatar Mar 08 '21 15:03 shadycuz

OK I'm taking a look now. Since I have zero experience with mypy, can you show me how I would quickly test a fix? (Dumb it down for me)

jeshan avatar Mar 09 '21 18:03 jeshan

... is supposed to be an instance of the class Filter

Also, tell me how did mypy come to know about the Filter type? It's Dict based on the data from boto3 so there must be something else going on here.

jeshan avatar Mar 09 '21 18:03 jeshan