shutil.rmtree: add avoids_symlink_attacks attribute (#9366)

This commit is contained in:
Alex Waygood
2022-12-15 09:56:58 +00:00
committed by GitHub
parent 9bddd3a3f1
commit c78bc57f78
2 changed files with 17 additions and 7 deletions

View File

@@ -2,7 +2,7 @@ import os
import sys
from _typeshed import BytesPath, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite
from collections.abc import Callable, Iterable, Sequence
from typing import Any, AnyStr, NamedTuple, TypeVar, overload
from typing import Any, AnyStr, NamedTuple, Protocol, TypeVar, overload
from typing_extensions import TypeAlias
__all__ = [
@@ -84,13 +84,22 @@ else:
_OnErrorCallback: TypeAlias = Callable[[Callable[..., Any], Any, Any], object]
if sys.version_info >= (3, 11):
def rmtree(
path: StrOrBytesPath, ignore_errors: bool = ..., onerror: _OnErrorCallback | None = ..., *, dir_fd: int | None = ...
) -> None: ...
class _RmtreeType(Protocol):
avoids_symlink_attacks: bool
if sys.version_info >= (3, 11):
def __call__(
self,
path: StrOrBytesPath,
ignore_errors: bool = ...,
onerror: _OnErrorCallback | None = ...,
*,
dir_fd: int | None = ...,
) -> None: ...
else:
def rmtree(path: StrOrBytesPath, ignore_errors: bool = ..., onerror: _OnErrorCallback | None = ...) -> None: ...
else:
def __call__(self, path: StrOrBytesPath, ignore_errors: bool = ..., onerror: _OnErrorCallback | None = ...) -> None: ...
rmtree: _RmtreeType
_CopyFn: TypeAlias = Callable[[str, str], object] | Callable[[StrPath, StrPath], object]

View File

@@ -165,6 +165,7 @@ poplib.POP3_SSL.stls # bad declaration of inherited function. See poplib.pyi
pyexpat.expat_CAPI
select.poll # Depends on configuration
selectors.DevpollSelector # Depends on configuration
shutil.rmtree # stubtest doesn't like that we have this as an instance of a callback protocol instead of a function
socketserver.BaseServer.RequestHandlerClass # is defined as a property, because we need `Self` type
socketserver.BaseServer.fileno # implemented in derived classes
socketserver.BaseServer.get_request # implemented in derived classes