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

@@ -11,6 +11,7 @@ from typing import (
TypeVar,
overload,
)
from typing_extensions import final
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
@@ -115,7 +116,7 @@ def __setitem__(a: MutableSequence[_T], b: slice, c: Sequence[_T]) -> None: ...
@overload
def __setitem__(a: MutableMapping[_K, _V], b: _K, c: _V) -> None: ...
def length_hint(__obj: Any, __default: int = ...) -> int: ...
@final
class attrgetter(Generic[_T_co]):
@overload
def __new__(cls, attr: str) -> attrgetter[Any]: ...
@@ -129,6 +130,7 @@ class attrgetter(Generic[_T_co]):
def __new__(cls, attr: str, *attrs: str) -> attrgetter[Tuple[Any, ...]]: ...
def __call__(self, obj: Any) -> _T_co: ...
@final
class itemgetter(Generic[_T_co]):
@overload
def __new__(cls, item: Any) -> itemgetter[Any]: ...
@@ -142,6 +144,7 @@ class itemgetter(Generic[_T_co]):
def __new__(cls, item: Any, *items: Any) -> itemgetter[Tuple[Any, ...]]: ...
def __call__(self, obj: Any) -> _T_co: ...
@final
class methodcaller:
def __init__(self, __name: str, *args: Any, **kwargs: Any) -> None: ...
def __call__(self, obj: Any) -> Any: ...