-
Notifications
You must be signed in to change notification settings - Fork 24.7k
Open
Labels
module: typingRelated to mypy type annotationsRelated to mypy type annotationstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🚀 Feature
Let users override __call__
of modules so that it works with type checking.
Motivation
This is a Module class I've been using over torch.nn.Module
so that I can override __call__
instead of forward
.
Pitch
When writing modules we override forward
, and invoke them through __call__
. In this setup
we can neither use static analysis tools to find errors nor use editor features such as viewing method signatures.
Additional context
Are there any side effects of using __init_subclass__
to rename __call__
implementations of subclasses to forward
?.
cc @ezyang
mdlockyer
Metadata
Metadata
Assignees
Labels
module: typingRelated to mypy type annotationsRelated to mypy type annotationstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module