-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] Implicit type aliases: Instantiation and attribute access #21672
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
base: main
Are you sure you want to change the base?
Conversation
Diagnostic diff on typing conformance testsChanges were detected when running ty on typing conformance tests--- old-output.txt 2025-11-28 08:43:48.579149249 +0000
+++ new-output.txt 2025-11-28 08:43:51.915166455 +0000
@@ -877,8 +877,6 @@
qualifiers_annotated.py:79:7: error[invalid-argument-type] Argument to function `func4` is incorrect: Expected `type[Unknown]`, found `<typing.Annotated special form>`
qualifiers_annotated.py:80:7: error[invalid-argument-type] Argument to function `func4` is incorrect: Expected `type[Unknown]`, found `<typing.Annotated special form>`
qualifiers_annotated.py:86:1: error[call-non-callable] Object of type `typing.Annotated` is not callable
-qualifiers_annotated.py:87:1: error[call-non-callable] Object of type `GenericAlias` is not callable
-qualifiers_annotated.py:88:1: error[call-non-callable] Object of type `GenericAlias` is not callable
qualifiers_final_annotation.py:18:7: error[invalid-type-form] Type qualifier `typing.Final` expected exactly 1 argument, got 2
qualifiers_final_annotation.py:54:9: error[invalid-assignment] Cannot assign to final attribute `ID5` in `__init__` because it already has a value at class level
qualifiers_final_annotation.py:65:9: error[invalid-assignment] Cannot assign to final attribute `ID7` on type `Self@method1`
@@ -1029,4 +1027,4 @@
typeddicts_usage.py:28:17: error[missing-typed-dict-key] Missing required key 'name' in TypedDict `Movie` constructor
typeddicts_usage.py:28:18: error[invalid-key] Unknown key "title" for TypedDict `Movie`: Unknown key "title"
typeddicts_usage.py:40:24: error[invalid-type-form] The special form `typing.TypedDict` is not allowed in type expressions
-Found 1031 diagnostics
+Found 1029 diagnostics
|
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
call-non-callable |
0 | 2 | 0 |
| Total | 0 | 2 | 0 |
|
Oh, the typing conformance suite results seem to suggest that we shouldn't do this: apparently the two lines where diagnostics are going away are places we're supposed to emit diagnostics. But it does make sense to me to just emulate what happens at runtime; I don't know why that rule exists in the spec (https://typing.python.org/en/latest/spec/qualifiers.html#annotated) |
Oh. I only looked at the |
Summary
Allow
Annotated[MyClass, …]instances to be instantiated.Test Plan
New Markdown tests.