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
feat: let ProxyMethod resolve callable attribute targets (#4915)
Summary:
Let `ProxyMethod` resolve a target declared as a class attribute, in addition to an ordinary instance method. A target is accepted whenever pyrefly can call it: `Callable[...]` annotations, callback protocols, and `type[X]` constructors all work but non-callable targets such as `forward: int` are still rejected.
This lets the shape stubs declare `nn.Module.forward` as `Callable[..., Any]`, matching PyTorch:
https://github.com/pytorch/pytorch/blob/d6c03540dc0f040e1d8a920d19d9333de6513545/torch/nn/modules/module.py#L526
The stubs previously declared `forward` as a method because that was the only target `ProxyMethod` could resolve. Under `strict-callable-subtyping`, a method-form `forward(*args, **kwargs)` makes every concrete `forward(self, x)` override a `bad-override`.
Pull Request resolved: #4915
Test Plan: Run `test.py`.
Reviewed By: stroxler
Differential Revision: D119805915
fbshipit-source-id: 5a7c941d69f3794e7896ee2bf0b3af9bd89e73a6
0 commit comments