mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[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:
committed by
PyTorch MergeBot
parent
c1dd3a615f
commit
67ef2683d9
@ -15,7 +15,6 @@ collection support for PyTorch APIs.
|
||||
import functools
|
||||
import sys
|
||||
import types
|
||||
import warnings
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
@ -28,6 +27,7 @@ from typing import (
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
from typing_extensions import deprecated
|
||||
|
||||
import torch
|
||||
|
||||
@ -167,6 +167,11 @@ def register_pytree_node(
|
||||
)
|
||||
|
||||
|
||||
@deprecated(
|
||||
"`torch.utils._cxx_pytree._register_pytree_node` is deprecated. "
|
||||
"Please use `torch.utils._cxx_pytree.register_pytree_node` instead.",
|
||||
category=FutureWarning,
|
||||
)
|
||||
def _register_pytree_node(
|
||||
cls: Type[Any],
|
||||
flatten_fn: FlattenFunc,
|
||||
@ -207,11 +212,6 @@ def _register_pytree_node(
|
||||
original context. This is used for json deserialization, which is being used in
|
||||
:mod:`torch.export` right now.
|
||||
"""
|
||||
warnings.warn(
|
||||
"torch.utils._cxx_pytree._register_pytree_node is deprecated. "
|
||||
"Please use torch.utils._cxx_pytree.register_pytree_node instead.",
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
_private_register_pytree_node(
|
||||
cls,
|
||||
|
Reference in New Issue
Block a user