-
Notifications
You must be signed in to change notification settings - Fork 250
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
Classmethod doesn't pass generic type #616
Comments
I assume you are talking about Python 3.7. If this is the case, then this will be tricky to implement, since in Python 3.7 (Also I hope you realize that |
@ilevkivskyi Yes this is Python 3.7. I tried this in Python 3.6.8 by changing the
I don't know enough about (Yes I'm aware they are no guarantees, as can be seen by having to change the code to work in Python 3.6.) |
This is a duplicate of #629 (or rather vice-versa, but the other issue has more context and a possible workaround). |
Type[type(cls(...))]
.classmethod
says a class method receives the class as implicit first argument.I'd assume that
Obj[int]
is it's own class, different fromObj
. Howeverclassmethod
doesn't work this way. This means that I can't useObj[int].from_str()
to make anObj[int]
, much like I can useObj.from_str()
to make anObj
. This can be seen in the following example.Which outputs:
It seems like
classmethod
and typing agree that it shouldn't be passed the generic type. However I think passing the type as well to be better than having to make allclassmethods
outside the class to support the generic type. It also doesn't look like it'd destroy current code ascls
seems to work the same way whether it's typed or not.The text was updated successfully, but these errors were encountered: