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

Fail gracefully on diverging recursive type aliases #13352

Merged
merged 2 commits into from
Aug 9, 2022

Conversation

ilevkivskyi
Copy link
Member

@ilevkivskyi ilevkivskyi commented Aug 7, 2022

This is another follow up on #13297.

We can't support aliases like Nested = Union[T, Nested[List[T]]] (and it looks like no-one can, without hacks like fixed type recursion limit). I would propose to just ban them for now. We can reconsider if people will ask for this.

cc @JukkaL

@github-actions

This comment has been minimized.

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2022

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

spark (https://github.com/apache/spark)
- python/pyspark/sql/pandas/map_ops.py:329: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/group_ops.py:255: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/group_ops.py:256: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/group_ops.py:333: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:73: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:83: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:94: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:106: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:119: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:133: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:148: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:157: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:158: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:161: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:170: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:180: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:191: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:203: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:216: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:230: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:245: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:250: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:251: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:255: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:256: error: Name "DataFrameLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:263: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:264: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:265: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:266: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:267: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:269: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:274: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:275: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:276: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:277: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:278: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:279: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:280: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:286: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:287: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:288: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:289: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:290: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:291: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:292: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:293: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:299: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:300: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:301: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:302: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:303: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:304: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:305: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:306: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:307: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:313: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:314: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:315: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:316: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:317: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:318: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:319: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:320: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:321: error: Name "SeriesLike" is not defined  [name-defined]
- python/pyspark/sql/pandas/functions.pyi:322: error: Name "SeriesLike" is not defined  [name-defined]

@ilevkivskyi
Copy link
Member Author

The old pyspark errors look totally bogus. There are not even some of the line numbers in that file. It is good they are gone. I even have an idea why: there was a very dangerously looking lookup() call in the code I was touching, and now it should be called less often. We should try to get rid of it (may be non trivial), or at least make it ignore errors (and just return None).

@ilevkivskyi
Copy link
Member Author

Sorry for not waiting for review here, it looks like this will help with another (more important) PR.

@ilevkivskyi ilevkivskyi merged commit cef452d into python:master Aug 9, 2022
@ilevkivskyi ilevkivskyi deleted the disable-divergent-aliases branch August 9, 2022 20:32
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