Skip to content

Fix heapq and _heapq stubs#15669

Open
jonathandung wants to merge 7 commits intopython:mainfrom
jonathandung:patch-1
Open

Fix heapq and _heapq stubs#15669
jonathandung wants to merge 7 commits intopython:mainfrom
jonathandung:patch-1

Conversation

@jonathandung
Copy link
Copy Markdown
Contributor

Closes #15666 and #15668.

@github-actions

This comment has been minimized.

Comment thread stdlib/_heapq.pyi Outdated
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread stdlib/_heapq.pyi Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

Diff from mypy_primer, showing the effect of this PR on open source code:

spark (https://github.com/apache/spark)
+ python/pyspark/shuffle.py:561: error: Argument "key" to "merge" has incompatible type "Callable[[V], Any] | None"; expected "Callable[[V], SupportsDunderLT[Any] | SupportsDunderGT[Any]]"  [arg-type]
+ python/pyspark/core/rdd.py:2575: error: Argument "key" to "nlargest" has incompatible type "Callable[[T], S] | None"; expected "Callable[[T], SupportsDunderLT[Any] | SupportsDunderGT[Any]]"  [arg-type]
+ python/pyspark/core/rdd.py:2578: error: Argument "key" to "nlargest" has incompatible type "Callable[[T], S] | None"; expected "Callable[[T], SupportsDunderLT[Any] | SupportsDunderGT[Any]]"  [arg-type]
+ python/pyspark/core/rdd.py:2635: error: Argument 3 to "nsmallest" has incompatible type "Callable[[T], S] | None"; expected "Callable[[T], SupportsDunderLT[Any] | SupportsDunderGT[Any]]"  [arg-type]
+ python/pyspark/core/rdd.py:2637: error: Argument 3 to "nsmallest" has incompatible type "Callable[[T], S] | None"; expected "Callable[[T], SupportsDunderLT[Any] | SupportsDunderGT[Any]]"  [arg-type]

@JelleZijlstra
Copy link
Copy Markdown
Member

The new pyspark errors in the mypy-primer output are unfortunate. Can we avoid them?

@jonathandung
Copy link
Copy Markdown
Contributor Author

They appear to be fixable by introducing a new type variable, but I don't know if it's worth the trouble to open an issue over there.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_heapq.heapify and _heapq.heapify_max do not required type variables to annotate

2 participants