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
Generic function type argument inference problem #230
This doesn't seem so easy to fix. We need to either make use of information learned from type checking the first argument to infer a type variable in the second argument (but what if the arguments were in the other order?) or be able to return a polymorphic type when type checking the second argument. I think the latter is easier and it's related to some other changes I want to make anyways (e.g. #1551), but it will require some reorganization.
Is there some syntax to pass type arguments explicitly when Python cannot infer the types? I am looking for something like this: f[str](x, []). If not, is there an issue or document when this "explicit passing of type arguments" feature is tracked?
Activity
JukkaL commentedon Mar 15, 2015
After #556 is done, this becomes more annoying.
rwbarton commentedon May 20, 2016
This doesn't seem so easy to fix. We need to either make use of information learned from type checking the first argument to infer a type variable in the second argument (but what if the arguments were in the other order?) or be able to return a polymorphic type when type checking the second argument. I think the latter is easier and it's related to some other changes I want to make anyways (e.g. #1551), but it will require some reorganization.
gvanrossum commentedon Jul 14, 2016
Based on Reid's comment I'm moving this to 0.5.0 (or maybe even later?).
earshinov commentedon Aug 14, 2019
Is there some syntax to pass type arguments explicitly when Python cannot infer the types? I am looking for something like this:
f[str](x, []). If not, is there an issue or document when this "explicit passing of type arguments" feature is tracked?ilevkivskyi commentedon Aug 14, 2019
@earshinov I think the best recent issue to discuss allowing explicit type application for functions is #6073.
Special-case type inference of empty collections (#16122)