Skip to content

OrderedDict cannot be assigned from tuple #789

@Josverl

Description

@Josverl

error: Argument of type "list[tuple[Literal['z'], Literal[1]] | tuple[Literal['a'], Literal[2]]]" cannot be assigned to parameter "map" of type "Mapping[_KT@OrderedDict, _VT@OrderedDict]" in function "__init__"

from collections import OrderedDict


d1 = OrderedDict()
d1["a"] = 1
d1["b"] = 2

d2 = OrderedDict({"a": 1, "b": 2})
d2["c"] = 3

# To make benefit of ordered keys, OrderedDict should be initialized
# from sequence of (key, value) pairs.
d3 = OrderedDict(
    [("z", 1), ("a", 2)]  # stubs-ignore:  linter in ["pyright"] or version < 1.24.0
)  # TODO: This @overload#3  used to work before a custom stdlib was added

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstdlibmicropython version of stdlib

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions