23 Aug
2022
23 Aug
'22
5:41 p.m.
Type annotations cannot contain complex expression forms like function calls. This is for good reason because type evaluation of call expressions can be very expensive, and different type checkers can produce different results (e.g. based on unspecified behaviors in overload resolution, heuristics used during TypeVar solving, etc.). For those reasons, I don't think this proposal would work. The technique you're using currently (your first code sample) is the approach I recommend. -- Eric Traut Contributor to Pyright & Pylance Microsoft