[BE] wrap deprecated function/class with typing_extensions.deprecated (#127689)

Use `typing_extensions.deprecated` for deprecation annotation if possible. Otherwise, add `category=FutureWarning` to `warnings.warn("message")` if the category is missing.

Note that only warnings that their messages contain `[Dd]eprecat(ed|ion)` are updated in this PR.

Resolves #126888

- #126888

This PR is split from PR #126898.

- #126898

------

Pull Request resolved: https://github.com/pytorch/pytorch/pull/127689
Approved by: https://github.com/Skylion007
This commit is contained in:
Xuehai Pan
2024-06-02 07:31:08 +00:00
committed by PyTorch MergeBot
parent c1dd3a615f
commit 67ef2683d9
97 changed files with 763 additions and 458 deletions

View File

@ -338,7 +338,7 @@ $1: f32[2] = torch._ops.prims.sin.default($0)""")
prims.mul(torch.randn(2), 1 + 1j)
def test_check_deprecation_warning(self):
with self.assertWarnsRegex(DeprecationWarning, 'will be removed in the future'):
with self.assertWarnsRegex(FutureWarning, 'will be removed in the future'):
torch._prims_common.check(True, lambda: 'message')