Add @final to slice/memoryview/range (#6289)

None of these classes can be subclassed at runtime.
This commit is contained in:
Alex Waygood
2021-11-14 02:03:56 +00:00
committed by GitHub
parent 9eabedca5f
commit f6e697f93e

View File

@@ -19,7 +19,6 @@ from _typeshed import (
SupportsRDivMod,
SupportsWrite,
)
from ast import AST, mod
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
from types import CodeType, MappingProxyType, TracebackType
from typing import (
@@ -62,6 +61,8 @@ from typing import (
)
from typing_extensions import Literal, SupportsIndex, TypeGuard, final
from _ast import AST
if sys.version_info >= (3, 9):
from types import GenericAlias
@@ -644,6 +645,7 @@ class bytearray(MutableSequence[int], ByteString):
def __gt__(self, __x: bytes) -> bool: ...
def __ge__(self, __x: bytes) -> bool: ...
@final
class memoryview(Sized, Sequence[int]):
format: str
itemsize: int
@@ -717,6 +719,7 @@ class bool(int):
def __rxor__(self, __x: int) -> int: ...
def __getnewargs__(self) -> tuple[int]: ...
@final
class slice(object):
start: Any
step: Any
@@ -937,6 +940,7 @@ class enumerate(Iterator[Tuple[int, _T]], Generic[_T]):
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
@final
class range(Sequence[int]):
start: int
stop: int
@@ -1010,7 +1014,7 @@ if sys.version_info >= (3, 10):
if sys.version_info >= (3, 8):
def compile(
source: str | bytes | mod | AST,
source: str | bytes | AST,
filename: str | bytes | _PathLike[Any],
mode: str,
flags: int = ...,
@@ -1022,7 +1026,7 @@ if sys.version_info >= (3, 8):
else:
def compile(
source: str | bytes | mod | AST,
source: str | bytes | AST,
filename: str | bytes | _PathLike[Any],
mode: str,
flags: int = ...,