Skip to content

heapq methods and asyncio.PriorityQueue missing appropriate comparison protocol bound #14418

Closed

Description

@mikeshardmind
import heapq

class A:
    ...

x: list[A] = []

heapq.heappush(x, A())
heapq.heappush(x, A())  # will raise at runtime

(similar cases constructable for other places where this is a problem)

The fix seems relatively trivial, so given that, I'm unsure if there's a reason this wasn't done already that would negatively impact existing use.

Surrounding context, this was noticed here,

Activity

  1. srittau commented on Jul 15, 2025

    @srittau
    Collaborator

    The relevant type var has been introduced ten years ago (3c4ace9), long before protocols were a thing, and never been revisited since then. PR welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions