Add @final to many unsubclassable stdlib classes (#6299)

This commit is contained in:
Alex Waygood
2021-11-15 13:45:24 +00:00
committed by GitHub
parent 5b94c6a94d
commit 10c9d8cfce
17 changed files with 48 additions and 9 deletions

View File

@@ -37,7 +37,7 @@ from typing import (
overload,
runtime_checkable,
)
from typing_extensions import Literal
from typing_extensions import Literal, final
from . import path as _path
@@ -262,6 +262,7 @@ if sys.platform != "win32":
TMP_MAX: int # Undocumented, but used by tempfile
# ----- os classes (structures) -----
@final
class stat_result:
# For backward compatibility, the return value of stat() is also
# accessible as a tuple of at least 10 integers giving the most important
@@ -314,6 +315,7 @@ class PathLike(Protocol[_AnyStr_co]):
_FdOrAnyPath = Union[int, StrOrBytesPath]
@final
class DirEntry(Generic[AnyStr]):
# This is what the scandir iterator yields
# The constructor is hidden
@@ -334,6 +336,7 @@ if sys.platform != "win32":
_Tuple11Int = Tuple[int, int, int, int, int, int, int, int, int, int, int]
if sys.version_info >= (3, 7):
# f_fsid was added in https://github.com/python/cpython/pull/4571
@final
class statvfs_result(_Tuple10Int): # Unix only
def __new__(cls, seq: _Tuple10Int | _Tuple11Int, dict: dict[str, int] = ...) -> statvfs_result: ...
n_fields: int
@@ -566,6 +569,7 @@ if sys.platform != "win32":
def readv(__fd: int, __buffers: Sequence[bytearray]) -> int: ...
def writev(__fd: int, __buffers: Sequence[bytes]) -> int: ...
@final
class terminal_size(Tuple[int, int]):
columns: int
lines: int