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
Support for functions producing generic functions (#3113)
Provides support for returning a generic Callable from a
function, allowing you to write a function that produces a
decorator, for example. This pattern is common:
```
def deco(x: int) -> Callable[[T], T]: ...
@Deco(4)
def f(stuff): ...
```
Details on why this touches so much code:
Returning a generic Callable from a function requires binding
type variables while we're traversing the type analysis phase of
the check. Previously, all type variable binding was done from
semanal.py. I refactored type variable tracking and binding into
its own class, that's used by both semanal.py and typeanal.py to
keep track of its type variables. I also, in the process, nixed
the thing where we're mutating TypeVarExprs to bind them, instead
keeping track of the bindings in the scope object I
created. Seems more sustainable in a world where more than one
class has to deal with typevar binding.
0 commit comments