Skip to content

Conversation

mtshiba
Copy link
Contributor

@mtshiba mtshiba commented Sep 9, 2025

Summary

From #17371

In #17371, DivergentType was introduced to prevent type inference for recursive functions from diverging and causing panics. This turned out to be useful for other divergent type inferences (#17371 (comment)), so I extracted the introduction part of DivergentType into this PR so that we can use it without waiting for the merge of #17371.

Note that this PR only introduces DivergentType and does not actually address divergent type inference yet. Please refer to https://github.com/astral-sh/ruff/pull/17371/files#diff-20b910c6e20faa962bb1642e111db1cbad8e66ace089bdd966ac9d7f9fa99ff2R542-R622 etc. when implementing handling of divergence suppression using this type.

Test Plan

Copy link
Contributor

github-actions bot commented Sep 9, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

Copy link
Contributor

github-actions bot commented Sep 9, 2025

mypy_primer results

No ecosystem changes detected ✅
No memory usage changes detected ✅

@mtshiba mtshiba marked this pull request as ready for review September 9, 2025 04:46
@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Sep 9, 2025
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you! I put together a proof-of-concept to show how we can use this type to address an infinite-tuple case in implicit instance attribute (given a small change in Salsa) -- that's enough to convince me that this will be generally useful.

@carljm carljm merged commit 8770b95 into astral-sh:main Sep 10, 2025
38 checks passed
@mtshiba mtshiba deleted the div-type branch September 12, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ty Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants