-
Notifications
You must be signed in to change notification settings - Fork 1.8k
StrEnum not recognized as a string by dictionary update #11354
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When using update, to update a dictionary, the keys of the dictionary are StrEnum, but pyright complains because it expects a str
Code or Screenshots
from enum import StrEnum
class Region(StrEnum):
NORTH = "north"
SOUTH = "south"
EAST = "east"
WEST = "west"
d1 = {Region.NORTH : 3}
d2 = {'one': 1, 'two' : 2}
d2.update(d1)That shows me:
WARNING: there is a new pyright version available (v1.1.407 -> v1.1.408).
Please install the new version or set PYRIGHT_PYTHON_FORCE_VERSION to `latest`
/home/acampove/Tests/pyright/str_enum/test.py
/home/acampove/Tests/pyright/str_enum/test.py:16:1 - error: No overloads for "update" match the provided arguments (reportCallIssue)
/home/acampove/Tests/pyright/str_enum/test.py:16:11 - error: Argument of type "dict[Region, int]" cannot be assigned to parameter "m" of type "Iterable[tuple[str, int]]" in function "update"
"dict[Region, int]" is not assignable to "Iterable[tuple[str, int]]"
Type parameter "_T_co@Iterable" is covariant, but "Region" is not a subtype of "tuple[str, int]"
"Region" is not assignable to "tuple[str, int]" (reportArgumentType)
2 errors, 0 warnings, 0 informations
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working