Make shutil.rmtree.onexc parameter optional (#12002)

This commit is contained in:
Avasam
2024-05-22 16:41:25 -04:00
committed by GitHub
parent 06efe457d4
commit 50cbca413c
2 changed files with 12 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
import os
import sys
from _typeshed import BytesPath, FileDescriptorOrPath, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite
from _typeshed import BytesPath, ExcInfo, FileDescriptorOrPath, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite
from collections.abc import Callable, Iterable, Sequence
from tarfile import _TarfileFilter
from typing import Any, AnyStr, NamedTuple, Protocol, TypeVar, overload
@@ -71,14 +71,12 @@ def copytree(
dirs_exist_ok: bool = False,
) -> _PathReturn: ...
_OnErrorCallback: TypeAlias = Callable[[Callable[..., Any], str, Any], object]
_OnExcCallback: TypeAlias = Callable[[Callable[..., Any], str, Exception], object]
_OnErrorCallback: TypeAlias = Callable[[Callable[..., Any], str, ExcInfo], object]
_OnExcCallback: TypeAlias = Callable[[Callable[..., Any], str, BaseException], object]
class _RmtreeType(Protocol):
avoids_symlink_attacks: bool
if sys.version_info >= (3, 12):
@overload
def __call__(self, path: StrOrBytesPath, ignore_errors: bool = False, *, dir_fd: int | None = None) -> None: ...
@overload
@deprecated("The `onerror` parameter is deprecated and will be removed in Python 3.14. Use `onexc` instead.")
def __call__(
@@ -91,7 +89,12 @@ class _RmtreeType(Protocol):
) -> None: ...
@overload
def __call__(
self, path: StrOrBytesPath, ignore_errors: bool = False, *, onexc: _OnExcCallback, dir_fd: int | None = None
self,
path: StrOrBytesPath,
ignore_errors: bool = False,
*,
onexc: _OnExcCallback | None = None,
dir_fd: int | None = None,
) -> None: ...
elif sys.version_info >= (3, 11):
def __call__(