upstash / redis-py

HTTP based Python Redis Client for Serverless and Edge Functions
https://docs.upstash.com/redis
MIT License
29 stars 3 forks source link

Type improvements #41

Closed ytkimirti closed 9 months ago

ytkimirti commented 9 months ago

I changed some from Dict to Mapping since

mytype = Dict[str, str]

def fn(arg: Dict[str, Union[str, int]]):
    pass

fn(key_value_pairs)

this gives

Argument of type "dict[str, str]" cannot be assigned to parameter "arg" of type "Dict[str, str | int]" in function "fn" "dict[str, str]" is incompatible with "Dict[str, str | int]" Type parameter "_VT@dict" is invariant, but "str" is not the same as "str | int" Consider switching from "dict" to "Mapping" which is covariant in the value typePylancereportGeneralTypeIssues