-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Custom abstract generic sub-classes #2291
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
Comments
You can write it like this:
You have to declare the type variables using a Would you like to contribute a fix (either a fix to #302 or a documentation update)? |
Leaving this open as a missing documentation issue. |
@JukkaL thanks for the fast response. I think I can make time for the documentation update, but I'll probably wait until I've answered a few more questions for myself. |
Um, PEP 484 is explicit that this should be allowed:
So I rather think that we should fix this instead of documenting it. (Though I'm okay with the fix being scheduled for Milestone 0.5 and the docs updated temporarily to explain the issue.) |
Yeah, I was aware of this -- #302 that I referred to above is about this. |
The second class definition fails type-checking with
Invalid type "mymodule.T"
:There's no documentation on creating custom abstract generic classes, and mypy and the typing tests have no examples of this either. The most obvious examples are those in
typing
itself, but it apparently uses techniques that are off limits outside oftyping
. I would love to know how to use multiple levels of inheritance to build up custom generics.This is related to #606 but I did not want to derail the discussion there as my issue is more focused on creating generics rather than aliasing them. Maybe just user error.
The text was updated successfully, but these errors were encountered: