Skip to content

heapq.merge, heapq.nlargest and heapq.nsmallest are typed inadequately #15668

@jonathandung

Description

@jonathandung

The current annotations for the above functions mean that their key arguments can be omitted for iterables of objects that do not implement the rich comparison operators without triggering a type checker diagnostic, whereas that will likely fail with TypeError at runtime. They should be overloaded accordingly.

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