Skip to content

Bug: No overload variant of "list" matches argument type "object" #9068

Closed
@MartinThoma

Description

@MartinThoma

MVCE

from typing import List, Tuple


def second(n: Tuple[int, str]) -> str:
    return n[1]


def get_sort_order(ids: List[str]) -> List[int]:
    sort_order_t = list(zip(*sorted(enumerate(ids), key=second)))[0]
    sort_order = list(sort_order_t)
    return sort_order


if __name__ == "__main__":
    ids = ["a", "b", "x", "c"]
    print(get_sort_order(ids))
    # [0, 1, 3, 2]

using mypy 0.782 I get:

$ python3.8 -m mypy example.py                                                                                                                                                                                <aws:joyn-dev>
example.py:10: error: No overload variant of "list" matches argument type "object"
example.py:10: note: Possible overload variant:
example.py:10: note:     def [_T] list(self, iterable: Iterable[_T]) -> List[_T]
example.py:10: note:     <1 more non-matching overload not shown>
Found 1 error in 1 file (checked 1 source file)

I expected this to run without an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions