New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[typing] nn.Parameter
return type identified as Tensor
by pyright
#125105
Comments
andoorve
pushed a commit
to andoorve/pytorch
that referenced
this issue
May 1, 2024
….Parameter` (pytorch#125106) Fixes pytorch#125105 Pull Request resolved: pytorch#125106 Approved by: https://github.com/ezyang, https://github.com/albanD
petrex
pushed a commit
to petrex/pytorch
that referenced
this issue
May 3, 2024
….Parameter` (pytorch#125106) Fixes pytorch#125105 Pull Request resolved: pytorch#125106 Approved by: https://github.com/ezyang, https://github.com/albanD
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🐛 Describe the bug
Type checking the following script with
pyright
fails (but not withmypy
):My guess what's happening:
TensorBase
defines:def __new__(self, *args, **kwargs) -> Tensor: ...
in the stubtorch/_C/__init__.pyi
Parameter.__new__
is untyped. Bothpyright
andmypy
show it'sself: type[Self@TensorBase] -> Tensor
, so reusing the superclasses type.mypy
ignores the discrepancy and treats the result as annn.Paramter
anyway.It seems the issue can be fixed by simply changing the signature in
TensorBase.__new__
toVersions
The text was updated successfully, but these errors were encountered: