Skip to content

Commit 50cbca4

Browse files
authored
Make shutil.rmtree.onexc parameter optional (#12002)
1 parent 06efe45 commit 50cbca4

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

stdlib/shutil.pyi

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import sys
3-
from _typeshed import BytesPath, FileDescriptorOrPath, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite
3+
from _typeshed import BytesPath, ExcInfo, FileDescriptorOrPath, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite
44
from collections.abc import Callable, Iterable, Sequence
55
from tarfile import _TarfileFilter
66
from typing import Any, AnyStr, NamedTuple, Protocol, TypeVar, overload
@@ -71,14 +71,12 @@ def copytree(
7171
dirs_exist_ok: bool = False,
7272
) -> _PathReturn: ...
7373

74-
_OnErrorCallback: TypeAlias = Callable[[Callable[..., Any], str, Any], object]
75-
_OnExcCallback: TypeAlias = Callable[[Callable[..., Any], str, Exception], object]
74+
_OnErrorCallback: TypeAlias = Callable[[Callable[..., Any], str, ExcInfo], object]
75+
_OnExcCallback: TypeAlias = Callable[[Callable[..., Any], str, BaseException], object]
7676

7777
class _RmtreeType(Protocol):
7878
avoids_symlink_attacks: bool
7979
if sys.version_info >= (3, 12):
80-
@overload
81-
def __call__(self, path: StrOrBytesPath, ignore_errors: bool = False, *, dir_fd: int | None = None) -> None: ...
8280
@overload
8381
@deprecated("The `onerror` parameter is deprecated and will be removed in Python 3.14. Use `onexc` instead.")
8482
def __call__(
@@ -91,7 +89,12 @@ class _RmtreeType(Protocol):
9189
) -> None: ...
9290
@overload
9391
def __call__(
94-
self, path: StrOrBytesPath, ignore_errors: bool = False, *, onexc: _OnExcCallback, dir_fd: int | None = None
92+
self,
93+
path: StrOrBytesPath,
94+
ignore_errors: bool = False,
95+
*,
96+
onexc: _OnExcCallback | None = None,
97+
dir_fd: int | None = None,
9598
) -> None: ...
9699
elif sys.version_info >= (3, 11):
97100
def __call__(
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
from _typeshed import Incomplete, StrOrBytesPath
1+
from _typeshed import StrOrBytesPath
2+
from shutil import _OnExcCallback
23

3-
def shutil_rmtree(path: StrOrBytesPath, ignore_errors: bool = False, onexc: Incomplete | None = None): ...
4+
def shutil_rmtree(path: StrOrBytesPath, ignore_errors: bool = False, onexc: _OnExcCallback | None = None): ...

0 commit comments

Comments
 (0)