-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Labels
module: nnRelated to torch.nnRelated to torch.nnmodule: 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
🐛 Describe the bug
nn.Module
is missing explicit typing for *args
and **kwargs
in its constructor.
For this reason, the following code generates an error in static type checkers like pyright, when using strict mode.
class MyModule(nn.Module):
def __init__(self, ...):
super().__init__() # Error: Type of "__init__" is partially unknown
To solve, the constructor of Module should be typed as
class Module:
def __init__(self, *args: Any, **kwargs: Any) -> None:
Versions
The torch version I am using is 2.7.0.
cc @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki @ezyang @malfet @xuzhao9 @gramster
Metadata
Metadata
Assignees
Labels
module: nnRelated to torch.nnRelated to torch.nnmodule: 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