Skip to content

Conversation

@AlexWaygood
Copy link
Member

Cc. @ilevkivskyi -- is there a risk that this could cause performance regressions for mypy? If so, then it may not be worth it.

@AlexWaygood AlexWaygood marked this pull request as ready for review November 8, 2022 16:54
@ilevkivskyi
Copy link
Member

I think it should be OK. Real problem is big unions, not recursive types per se, recursive types just exaggerate problems with big unions.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2022

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

discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/converter.py:1177: error: Argument 2 to "issubclass" has incompatible type "_SpecialForm"; expected "Union[type, UnionType, Tuple[Union[type, UnionType, Tuple[Any, ...]], ...]]"  [arg-type]
+ discord/ext/commands/converter.py:1177: error: Argument 2 to "issubclass" has incompatible type "_SpecialForm"; expected "_ClassInfo"  [arg-type]
- discord/ext/commands/hybrid.py:206: error: Argument 2 to "isinstance" has incompatible type "_SpecialForm"; expected "Union[type, UnionType, Tuple[Union[type, UnionType, Tuple[Any, ...]], ...]]"  [arg-type]
+ discord/ext/commands/hybrid.py:206: error: Argument 2 to "isinstance" has incompatible type "_SpecialForm"; expected "_ClassInfo"  [arg-type]

@AlexWaygood
Copy link
Member Author

I think it should be OK. Real problem is big unions, not recursive types per se, recursive types just exaggerate problems with big unions.

I was worried about isinstance()/issubclass(), since they're such fundamental functions :) Thanks for taking a look!

@AlexWaygood AlexWaygood merged commit 7394602 into main Nov 8, 2022
@AlexWaygood AlexWaygood deleted the recursion branch November 8, 2022 17:04
@AlexWaygood AlexWaygood mentioned this pull request Nov 8, 2022
5 tasks
@hauntsaninja
Copy link
Collaborator

@ilevkivskyi this PR causes mypy to crash with RecursionError when using --any-exprs-report, want to take a look? python/mypy#14130

@ilevkivskyi
Copy link
Member

OK, I can take a look

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.

4 participants