forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_warnings.py
44 lines (31 loc) · 1.22 KB
/
_warnings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
"""Decorators used to warn about non-stable APIs."""
# pyre-strict
from typing import Any, Dict, Optional, Sequence, Type
from typing_extensions import deprecated
__all__ = ["deprecated", "experimental"]
class ExperimentalWarning(DeprecationWarning):
"""Emitted when calling an experimental API.
Derives from DeprecationWarning so that it is similarly filtered out by
default.
"""
def __init__(self, /, *args: Sequence[Any], **kwargs: Dict[str, Any]) -> None:
super().__init__(*args, **kwargs)
class experimental(deprecated):
"""Indicates that a class, function or overload is experimental.
When this decorator is applied to an object, the type checker
will generate a diagnostic on usage of the experimental object.
"""
def __init__(
self,
message: str,
/,
*,
category: Optional[Type[Warning]] = ExperimentalWarning,
stacklevel: int = 1,
) -> None:
super().__init__(message, category=category, stacklevel=stacklevel)