Skip to content

Fix heapq and _heapq stubs#15669

Open
jonathandung wants to merge 9 commits into
python:mainfrom
jonathandung:patch-1
Open

Fix heapq and _heapq stubs#15669
jonathandung wants to merge 9 commits into
python:mainfrom
jonathandung:patch-1

Conversation

@jonathandung
Copy link
Copy Markdown
Contributor

@jonathandung jonathandung commented Apr 23, 2026

Closes #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

This comment has been minimized.

@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.

@github-actions
Copy link
Copy Markdown
Contributor

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

spark (https://github.com/apache/spark)
+ python/pyspark/shuffle.py:556: 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]

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.merge, heapq.nlargest and heapq.nsmallest are typed inadequately

2 participants