You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4d4c8fa
Browse filesBrowse the repository at this point in the historyBrowse files
[ty] Emit diagnostic when specializing a non-generic class (#26883)
## Summary
Emit `not-subscriptable` when a non-generic class is specialized in a
type expression, and recover as `Unknown` instead of an internal `@Todo`
type.
This highlighted some scenarios in the ecosystem result where
`not-subscriptable` is being emitted but it might not be ideal, refer to
my inline comments. I've added mdtest cases for these looking at the
ecosystem result.
Closesastral-sh/ty#2439.
## Test plan
Update the mdtest
## Specializing classes with unavailable generic context
162
+
163
+
When an earlier error prevents ty from determining a class's generic context, specializing the class
164
+
can emit a cascading `not-subscriptable` diagnostic.
165
+
166
+
### Conditional typing compatibility imports
167
+
168
+
Libraries support multiple Python versions by importing generic machinery from either
169
+
`typing_extensions` or `typing`. ty does not yet recognize the resulting union as the corresponding
170
+
typing special form.
171
+
172
+
```py
173
+
try:
174
+
import typing_extensions as typing
175
+
exceptImportError:
176
+
import typing
177
+
178
+
T = typing.TypeVar("T")
179
+
180
+
#TODO: Fix the conditional typing import in https://github.com/astral-sh/ty/issues/1585.
181
+
# error: [invalid-argument-type] "`typing_extensions.TypeVar | typing.TypeVar` is not a valid argument to `Generic`"
182
+
classParser(typing.Generic[T]): ...
183
+
184
+
#TODO: Remove this cascading error when https://github.com/astral-sh/ty/issues/1585 is fixed.
0 commit comments