Skip to content

Conversation

ytkimirti
Copy link
Collaborator

@ytkimirti ytkimirti commented Nov 23, 2023

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

@ytkimirti ytkimirti merged commit a1a8851 into main Nov 28, 2023
@mdumandag mdumandag deleted the type-changes branch November 28, 2023 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants