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
[BE] Make legacy type storage warning point to the caller #113601
Conversation
`@classproperty` adds another wrapper, so warning would always point to the wrapper implementation rather than at callee. For example, before this change following code ```python import torch print(torch.FloatStorage.dtype) ``` will produce inactionable warning: ``` /Users/nshulga/git/pytorch/pytorch/torch/_utils.py:836: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() return self.fget.__get__(instance, owner)() ``` But after the change warning turns into: ``` /Users/nshulga/test/bar.py:2: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() print(torch.FloatStorage.dtype) ```
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/113601
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit d459f16 with merge base a43c757 (): This comment was automatically generated by Dr. CI and updates every 15 minutes. |
I have a global ruff rule to ban warnings without an explicit stack level, but I haven't gotten around to enabling it. |
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…3601) `@classproperty` decorator adds another wrapper, so warning with default stacklevel (2) would always point to the wrapper implementation rather than at callee. For example, before this change following code ```python import torch print(torch.FloatStorage.dtype) ``` will produce inactionable warning: ``` /Users/nshulga/git/pytorch/pytorch/torch/_utils.py:836: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() return self.fget.__get__(instance, owner)() ``` But after the change warning turns into: ``` /Users/nshulga/test/bar.py:2: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() print(torch.FloatStorage.dtype) ``` Discovered while reading pytorch#109108 Pull Request resolved: pytorch#113601 Approved by: https://github.com/kit1980
@classproperty
decorator adds another wrapper, so warning with default stacklevel (2) would always point to the wrapper implementation rather than at callee.For example, before this change following code
will produce inactionable warning:
But after the change warning turns into:
Discovered while reading #109108