Add explicit typing to nn.Module.__init__() parameters (#157389)

Fixes #156740

Adds explicit `Any` typing to `*args` and `**kwargs` in `nn.Module.__init__()` to fix type checker errors in strict mode.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/157389
Approved by: https://github.com/Skylion007, https://github.com/Raman-RH
This commit is contained in:
dsashidh
2025-09-19 19:02:23 +00:00
committed by PyTorch MergeBot
parent 52dd7a898c
commit 03f34fd307

View File

@ -476,7 +476,7 @@ class Module:
call_super_init: bool = False
_compiled_call_impl: Optional[Callable] = None
def __init__(self, *args, **kwargs) -> None:
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""Initialize internal Module state, shared by both nn.Module and ScriptModule."""
torch._C._log_api_usage_once("python.nn_module")