-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathcopy.pyi
More file actions
32 lines (23 loc) · 946 Bytes
/
copy.pyi
File metadata and controls
32 lines (23 loc) · 946 Bytes
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
import sys
from typing import Any, Protocol, TypeVar, type_check_only
from typing_extensions import ParamSpec
__all__ = ["Error", "copy", "deepcopy"]
_T = TypeVar("_T")
_RT_co = TypeVar("_RT_co", covariant=True)
_P = ParamSpec("_P")
@type_check_only
class _SupportsReplace(Protocol[_P, _RT_co]):
# In reality doesn't support args, but there's no great way to express this.
def __replace__(self, /, *_: _P.args, **changes: _P.kwargs) -> _RT_co: ...
# None in CPython but non-None in Jython
PyStringMap: Any
# Note: memo and _nil are internal kwargs.
def deepcopy(x: _T, memo: dict[int, Any] | None = None, _nil: Any = []) -> _T: ...
def copy(x: _T) -> _T: ...
if sys.version_info >= (3, 13):
__all__ += ["replace"]
def replace(
obj: _SupportsReplace[_P, _RT_co], /, *_: _P.args, **changes: _P.kwargs # does not accept positional arguments at runtime
) -> _RT_co: ...
class Error(Exception): ...
error = Error