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

Make is_recursive and has_recursive_types() more consistent #14147

Merged
merged 2 commits into from
Nov 19, 2022

Conversation

ilevkivskyi
Copy link
Member

While working on another PR I noticed that current behavior of has_recursive_types() is inconsistent, it returns False is there is a recursive type nested as an argument to a generic non-recursive alias. I wasn't able to find any situation where this actually matters, but I think it is better if this function behaves consistently.

cc @JukkaL @hauntsaninja

@github-actions

This comment has been minimized.

@ilevkivskyi
Copy link
Member Author

Actually it looks like is_recursive property is also inconsistent, it can return True for an alias that is not recursive itself, but has a recursive argument, and then this value is cached. I think it is actually best to resolve to inconsistencies together, since they kind of compensate each other. I will also add a unit test.

@ilevkivskyi ilevkivskyi changed the title Make has_recursive_types() more consistent Make is_recursive and has_recursive_types() more consistent Nov 19, 2022
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@ilevkivskyi
Copy link
Member Author

If there are no objections, I am going to merge this later today.

@ilevkivskyi ilevkivskyi merged commit f8d71f1 into python:master Nov 19, 2022
@ilevkivskyi ilevkivskyi deleted the fix-recursive-context branch November 19, 2022 22:54
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.

None yet

1 participant