Skip to content

sorted() does not enforce comparable items in an iterable of tuples #13297

Open
@jcmacdon

Description

sorted() does not enforce that every item in the tuple must be comparable:

items: list[tuple[int, object]] = [(1, object()), (1, object())]
sorted(items)

typeshed/stdlib/builtins.pyi

Lines 1762 to 1767 in e5c5318

@overload
def sorted(
iterable: Iterable[SupportsRichComparisonT], /, *, key: None = None, reverse: bool = False
) -> list[SupportsRichComparisonT]: ...
@overload
def sorted(iterable: Iterable[_T], /, *, key: Callable[[_T], SupportsRichComparison], reverse: bool = False) -> list[_T]: ...

Metadata

Assignees

No one assigned

    Labels

    stubs: false negativeType checkers do not report an error, but should

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions