Skip to content

Make is_recursive and has_recursive_types() more consistent#14147

Merged
ilevkivskyi merged 2 commits intopython:masterfrom
ilevkivskyi:fix-recursive-context
Nov 19, 2022
Merged

Make is_recursive and has_recursive_types() more consistent#14147
ilevkivskyi merged 2 commits intopython:masterfrom
ilevkivskyi:fix-recursive-context

Conversation

@ilevkivskyi
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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

@ilevkivskyi
Copy link
Copy Markdown
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.

1 participant