-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] Evaluate reachability of non-definitely-bound to Ambiguous #19579
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
[ty] Evaluate reachability of non-definitely-bound to Ambiguous #19579
Conversation
|
CodSpeed WallTime Performance ReportMerging #19579 will not alter performanceComparing Summary
|
CodSpeed Instrumentation Performance ReportMerging #19579 will not alter performanceComparing Summary
|
This comment was marked as resolved.
This comment was marked as resolved.
d5dafc5
to
3430eea
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
d383152
to
b05868f
Compare
b05868f
to
9be1e82
Compare
9be1e82
to
feca174
Compare
This comment was marked as resolved.
This comment was marked as resolved.
feca174
to
590ea0d
Compare
aa650e9
to
a84b8ce
Compare
Thank you for the feedback. I'm drafting the PR to apply the suggestion. |
…s-not-definitely-bound
I'm looking into making the changes described above. |
4c1da8c
to
2218db4
Compare
94d1897
to
71bd443
Compare
|
Lint rule | Added | Removed | Changed |
---|---|---|---|
unresolved-attribute |
20 | 0 | 0 |
possibly-unbound-attribute |
7 | 0 | 0 |
possibly-unresolved-reference |
2 | 0 | 0 |
Total | 29 | 0 | 0 |
…tions (#20114) ## Summary Properly preserve type qualifiers when accessing attributes on unions and intersections. This is a prerequisite for #19579. Also fix a completely wrong implementation of `map_with_boundness_and_qualifiers`. It now closely follows `map_with_boundness` (just above). ## Test Plan I thought about it, but didn't find any easy way to test this. This only affected `Type::member`. Things like validation of attribute writes (where type qualifiers like `ClassVar` and `Final` are important) were already handling things correctly.
…s-not-definitely-bound
966553c
to
a18a7ce
Compare
I tried various other solutions here, and non of them worked as well as what @Glyphack implemented in the first place. The main problem is that we can only build unions/intersections of types. We can't build unions/intersections of I also tried various completely different approaches of solving this problem, and none of them hit the right granularity. Either they are not able to solve the So I am returning this PR to a previous state (with a couple of smaller cleanups, renamings, and additional tests). I am still not very satisfied with the fact that we track boundness information in a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you again, @Glyphack!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
crates/ty_python_semantic/resources/mdtest/statically_known_branches.md
Outdated
Show resolved
Hide resolved
* main: Fix mdtest ignore python code blocks (#20139) [ty] add support for cyclic legacy generic protocols (#20125) [ty] add cycle detection for find_legacy_typevars (#20124) Use new diff rendering format in tests (#20101) [ty] Fix 'too many cycle iterations' for unions of literals (#20137) [ty] No boundness analysis for implicit instance attributes (#20128) Bump 0.12.11 (#20136) [ty] Benchmarks for problematic implicit instance attributes cases (#20133) [`pyflakes`] Fix `allowed-unused-imports` matching for top-level modules (`F401`) (#20115) Move GitLab output rendering to `ruff_db` (#20117) [ty] Evaluate reachability of non-definitely-bound to Ambiguous (#19579) [ty] Introduce a representation for the top/bottom materialization of an invariant generic (#20076) [`flake8-async`] Implement `blocking-http-call-httpx` (`ASYNC212`) (#20091) [ty] print diagnostics with fully qualified name to disambiguate some cases (#19850) [`ruff`] Preserve relative whitespace in multi-line expressions (`RUF033`) (#19647)
…tions (astral-sh#20114) ## Summary Properly preserve type qualifiers when accessing attributes on unions and intersections. This is a prerequisite for astral-sh#19579. Also fix a completely wrong implementation of `map_with_boundness_and_qualifiers`. It now closely follows `map_with_boundness` (just above). ## Test Plan I thought about it, but didn't find any easy way to test this. This only affected `Type::member`. Things like validation of attribute writes (where type qualifiers like `ClassVar` and `Final` are important) were already handling things correctly.
…al-sh#19579) ## Summary closes astral-sh/ty#692 If the expression (or any child expressions) is not definitely bound the reachability constraint evaluation is determined as ambiguous. This fixes the infinite cycles panic in the following code: ```py from typing import Literal class Toggle: def __init__(self: "Toggle"): if not self.x: self.x: Literal[True] = True ``` Credit of this solution is for David. ## Test Plan - Added a test case with too many cycle iterations panic. - Previous tests. --------- Co-authored-by: David Peter <[email protected]>
Summary
closes astral-sh/ty#692
If the expression (or any child expressions) is not definitely bound the reachability constraint evaluation is determined as ambiguous.
This fixes the infinite cycles panic in the following code:
Credit of this solution is for David.
Test Plan