Message382213
FWIW, current code for extracting args type and return type from Callable seems to be something like this (at least from the typing module):
arg_types = __args__[:-1]
return_type = __args__[-1]
Once ParamSpec is added in, library authors would need to check specifically for that in arg_types and return_types. Other than that, I don't have enough expertise or experience to say what will/won't break.
IMO a flat tuple is ok for now: AFAIK (and I might be completely wrong here), most runtime type checking libraries I've used don't validate the arguments passed in because being too strict may interfere with keyword arguments. (Eg. Callable in Pydantic https://pydantic-docs.helpmanual.io/usage/types/#callable). So the slightly more inconvenient way of reading Callable's __args__ seems to be an acceptable tradeoff for backwards compatibility and simplicity. |
|
Date |
User |
Action |
Args |
2020-12-01 02:24:57 | kj | set | recipients:
+ kj, gvanrossum, serhiy.storchaka, levkivskyi, corona10, Zac Hatfield-Dodds, BTaskaya, hauntsaninja |
2020-12-01 02:24:57 | kj | set | messageid: <1606789497.34.0.639103249814.issue42195@roundup.psfhosted.org> |
2020-12-01 02:24:57 | kj | link | issue42195 messages |
2020-12-01 02:24:55 | kj | create | |
|