-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[ty] Fallback to Unknown if no type is stored for an expression #19517
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
Conversation
|
I don't know what's up with "CodSpeed Macro Runners" but I don't think it's related to this PR. |
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.
👍 I like this. There are definitely places where we're currently jumping through extra hoops to infer a type for every expression, but we can simplify those as needed moving forward.
This also opens the door for storing separate value form and type form types for each expression, I think? That would in turn let us simplify parts of the call binding machinery.
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.
This also resolves astral-sh/ty#865 (I tested this PR locally on the examples mentioned in that issue), it might be useful to add a couple of test cases from that issue.
I think it's worth a try and we can always come back if it makes tracking down bugs harder What I would find useful is to add least log a tracing debug message if we take the fallback branch |
I thought about that as well. In https://github.com/astral-sh/ruff/pull/19478/files#r2223870292, I suggested that we might only want to do that in valid code (and in this case, it could even be an error?). Because otherwise, if the |
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.
I agree that some logging for the fallback case might be good, but also that it might be hard to stop that from being very noisy in an IDE context. Even if you only emit the logs when there's valid syntax, there are lots of situations where you might have valid syntax but an invalid type expression when you're halfway through typing an annotation
That's a fair concern. I don't think it should impact most users because the LSP only shows info level logs by default. |
4fa7e0e
to
53103b3
Compare
The tracing feels likely to be quite noisy to me, I would rather try without it -- if anyone finds themselves debugging a case like this and the tracing would have helped, we can add it. |
Changes which I chose not to include; let me know if one of these should be added: ``` - Add warning for unknown `TY_MEMORY_REPORT` value ([#19465](astral-sh/ruff#19465)) - Add goto definition to playground ([#19425](astral-sh/ruff#19425)) - Added support for "go to references" in ty playground. ([#19516](astral-sh/ruff#19516)) - Fall back to `Unknown` if no type is stored for an expression ([#19517](astral-sh/ruff#19517)) - Make `Module` a Salsa ingredient ([#19495](astral-sh/ruff#19495)) - Return a tuple spec from the iterator protocol ([#19496](astral-sh/ruff#19496)) ``` --------- Co-authored-by: Alex Waygood <[email protected]>
## Summary See discussion at https://github.com/astral-sh/ruff/pull/19478/files#r2223870292 Fixes astral-sh/ty#865 ## Test Plan Added one mdtest for invalid Callable annotation; removed `pull-types: skip` from that test file. Co-authored-by: lipefree <[email protected]>
Summary
See discussion at https://github.com/astral-sh/ruff/pull/19478/files#r2223870292
Fixes astral-sh/ty#865
Test Plan
Added one mdtest for invalid Callable annotation; removed
pull-types: skip
from that test file.Co-authored-by: lipefree [email protected]