Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only defer top-level functions #18718

Merged
merged 3 commits into from
Feb 21, 2025

Conversation

ilevkivskyi
Copy link
Member

This makes deferral logic more robust and more consistent with fine-grained mode. I also:

  • Change some terminology, as "top function" is ambiguous: top-level function vs top of stack function.
  • Update some docs and type annotations to match actual behavior (e.g. we do not defer lambdas)

See also #18674 for some more motivation.

This comment has been minimized.

Copy link
Contributor

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

steam.py (https://github.com/Gobot1234/steam.py)
- steam/abc.py:667: error: Argument 3 to "_from_proto" of "Review" has incompatible type "PartialUser"; expected "User | ClientUser"  [arg-type]

static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/archive_npy.py:1185: error: Unused "type: ignore" comment  [unused-ignore]

spark (https://github.com/apache/spark)
+ python/pyspark/util.py:434: error: Unused "type: ignore" comment  [unused-ignore]
+ python/pyspark/util.py:458: error: Unused "type: ignore[misc, operator]" comment  [unused-ignore]
+ python/pyspark/pandas/frame.py:6413: error: Argument "value" to "replace" of "Series" has incompatible type "int | float | str | list[Any] | tuple[Any, ...] | dict[Any, Any]"; expected "list[Any] | tuple[Any, ...]"  [arg-type]
+ python/pyspark/pandas/namespace.py:2288: error: Unused "type: ignore" comment  [unused-ignore]
+ python/pyspark/pandas/namespace.py:2291: error: Unused "type: ignore" comment  [unused-ignore]

@ilevkivskyi
Copy link
Member Author

The only new error looks correct, as now we apply narrowing from binder (Any -> something more precise).

@ilevkivskyi ilevkivskyi merged commit 256cf68 into python:master Feb 21, 2025
18 checks passed
@ilevkivskyi ilevkivskyi deleted the defer-top-level-funcs branch February 21, 2025 23:20
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.

1 participant