Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jcmacdon opened this issue Dec 24, 2024 · 1 comment
Open

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

jcmacdon opened this issue Dec 24, 2024 · 1 comment
Labels
stubs: false negative Type checkers do not report an error, but should

Comments

@jcmacdon
Copy link

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]: ...

@AlexWaygood AlexWaygood added the stubs: false negative Type checkers do not report an error, but should label Dec 24, 2024
@ajaya0
Copy link

ajaya0 commented Dec 25, 2024

Hi @jcmacdon ,
Can you explain the issue in more detail so that I can resolve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false negative Type checkers do not report an error, but should
Projects
None yet
Development

No branches or pull requests

3 participants