Skip to content

Fix heapq and _heapq stubs#15669

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

Fix heapq and _heapq stubs#15669
jonathandung wants to merge 5 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
Copy link
Copy Markdown
Contributor

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

dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ddtrace/debugging/_encoding.py:286: error: Argument 1 to "heapify" has incompatible type "list[Node]"; expected "list[SupportsDunderLT[Any] | SupportsDunderGT[Any]]"  [arg-type]
+ ddtrace/debugging/_encoding.py:286: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
+ ddtrace/debugging/_encoding.py:286: note: Consider using "Sequence" instead, which is covariant

async-utils (https://github.com/mikeshardmind/async-utils)
+ src/async_utils/_graphs.py:204: error: Argument 1 to "heapify" has incompatible type "list[tuple[HashAndCompareT, NodeData[HashAndCompareT]]]"; expected "list[SupportsDunderLT[Any] | SupportsDunderGT[Any]]"  [arg-type]
+ src/async_utils/_graphs.py:204: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
+ src/async_utils/_graphs.py:204: note: Consider using "Sequence" instead, which is covariant

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]

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/cookiejar.py:259:27: error: Argument 1 to "heapify" has incompatible type "list[tuple[float, tuple[str, str, str]]]"; expected "list[SupportsDunderLT[Any] | SupportsDunderGT[Any]]"  [arg-type]
+ aiohttp/cookiejar.py:259:27: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
+ aiohttp/cookiejar.py:259:27: note: Consider using "Sequence" instead, which is covariant

trio (https://github.com/python-trio/trio)
+ src/trio/_core/_run.py:303: error: Argument 1 to "heapify" has incompatible type "list[tuple[float, int, CancelScope]]"; expected "list[SupportsDunderLT[Any] | SupportsDunderGT[Any]]"  [arg-type]
+ src/trio/_core/_run.py:303: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
+ src/trio/_core/_run.py:303: note: Consider using "Sequence" instead, which is covariant

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