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

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.

UPDATE: Use `FutureWarning` instead of `DeprecationWarning`.

Resolves #126888

- #126888

Pull Request resolved: https://github.com/pytorch/pytorch/pull/126898
Approved by: https://github.com/albanD
This commit is contained in:
Xuehai Pan
2024-05-29 12:09:24 +00:00
committed by PyTorch MergeBot
parent 699db7988d
commit 749a132fb0
117 changed files with 700 additions and 478 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')