-
Notifications
You must be signed in to change notification settings - Fork 394
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
Update test cases to work on 3.11 #178
Conversation
hillary-mutisya
commented
Feb 8, 2024
- use the pre-3.11 approach for declaring generic classes and typealiastype
- check for both typing.TypedDict and typing_extensions.TypedDict in _KNOWN_SPECIAL_BASES
T = TypeVar("T", covariant=True) | ||
|
||
|
||
class First(Generic[T], TypedDict): |
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.
Currently TypeChat only understands generics using 3.12 syntax. It doesn't consider types that extend Generic[...]
or generic protocols as adding type parameters. So I think we either find a way to make some of these tests only run in 3.12, or temporarily disable them.
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 updated the TypeChat code to read type parameters for the classes that extend Generic[...] from the parameters field. With this, the generic_alias_1.py test now outputs type info correctly:
// Entry point is: 'FirstOrSecond'
// TypeScript Schema:
type FirstOrSecond<T> = First<T> | Second<T>
interface Second<T> {
kind: "second";
"second_attr": T;
}
interface First<T> {
kind: "first";
"first_attr": T;
}
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.
Looks good.
… that inherit from Generic[T]
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.
Updated based on PR feedback