-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[ty] Add subdiagnostic hint if the user wrote X = Any rather than X: Any
#21777
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
Diagnostic diff on typing conformance testsChanges were detected when running ty on typing conformance tests--- old-output.txt 2025-12-03 17:36:22.183723401 +0000
+++ new-output.txt 2025-12-03 17:36:25.927749245 +0000
@@ -915,7 +915,7 @@
specialtypes_type.py:120:5: error[unresolved-attribute] Object of type `type` has no attribute `unknown`
specialtypes_type.py:137:5: error[type-assertion-failure] Type `type[Any]` does not match asserted type `type`
specialtypes_type.py:139:5: error[type-assertion-failure] Type `type[Any]` does not match asserted type `type`
-specialtypes_type.py:143:1: error[unresolved-attribute] Object of type `typing.Type` has no attribute `unknown`
+specialtypes_type.py:143:1: error[unresolved-attribute] Special form `typing.Type` has no attribute `unknown`
specialtypes_type.py:145:1: error[unresolved-attribute] Class `type` has no attribute `unknown`
specialtypes_type.py:169:21: error[invalid-assignment] Object of type `type` is not assignable to `type[int]`
specialtypes_type.py:175:16: error[invalid-return-type] Return type does not match returned value: expected `type[T@ClassA]`, found `type`
|
|
|
The ecosystem impact seems fine. Those |
sharkdp
left a comment
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.
Cool — thank you!
| fn is_dotted_name(attribute: &ast::Expr) -> bool { | ||
| match attribute { | ||
| ast::Expr::Name(_) => true, | ||
| ast::Expr::Attribute(ast::ExprAttribute { value, .. }) => is_dotted_name(value), | ||
| _ => false, | ||
| } | ||
| } |
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.
Is it worth reusing this (also used in is_if_type_checking)? Fine if not, it's short enough.
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 think I'll pass -- it's a tiny routine, and semantic_index/builder.rs feels like a long way away from this code.
| maybe_n = if attr_name.starts_with(['a', 'e', 'i', 'o', 'u']) { | ||
| "n" | ||
| } else { | ||
| "" | ||
| }, |
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.
🥇
Fixes astral-sh/ty#1744