Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f6e697f

Browse filesBrowse files
authored
Add @final to slice/memoryview/range (#6289)
None of these classes can be subclassed at runtime.
1 parent 9eabedc commit f6e697f
Copy full SHA for f6e697f

File tree

Expand file treeCollapse file tree

1 file changed

+7
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-3
lines changed

‎stdlib/builtins.pyi

Copy file name to clipboardExpand all lines: stdlib/builtins.pyi
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ from _typeshed import (
1919
SupportsRDivMod,
2020
SupportsWrite,
2121
)
22-
from ast import AST, mod
2322
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
2423
from types import CodeType, MappingProxyType, TracebackType
2524
from typing import (
@@ -62,6 +61,8 @@ from typing import (
6261
)
6362
from typing_extensions import Literal, SupportsIndex, TypeGuard, final
6463

64+
from _ast import AST
65+
6566
if sys.version_info >= (3, 9):
6667
from types import GenericAlias
6768

@@ -644,6 +645,7 @@ class bytearray(MutableSequence[int], ByteString):
644645
def __gt__(self, __x: bytes) -> bool: ...
645646
def __ge__(self, __x: bytes) -> bool: ...
646647

648+
@final
647649
class memoryview(Sized, Sequence[int]):
648650
format: str
649651
itemsize: int
@@ -717,6 +719,7 @@ class bool(int):
717719
def __rxor__(self, __x: int) -> int: ...
718720
def __getnewargs__(self) -> tuple[int]: ...
719721

722+
@final
720723
class slice(object):
721724
start: Any
722725
step: Any
@@ -937,6 +940,7 @@ class enumerate(Iterator[Tuple[int, _T]], Generic[_T]):
937940
if sys.version_info >= (3, 9):
938941
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
939942

943+
@final
940944
class range(Sequence[int]):
941945
start: int
942946
stop: int
@@ -1010,7 +1014,7 @@ if sys.version_info >= (3, 10):
10101014

10111015
if sys.version_info >= (3, 8):
10121016
def compile(
1013-
source: str | bytes | mod | AST,
1017+
source: str | bytes | AST,
10141018
filename: str | bytes | _PathLike[Any],
10151019
mode: str,
10161020
flags: int = ...,
@@ -1022,7 +1026,7 @@ if sys.version_info >= (3, 8):
10221026

10231027
else:
10241028
def compile(
1025-
source: str | bytes | mod | AST,
1029+
source: str | bytes | AST,
10261030
filename: str | bytes | _PathLike[Any],
10271031
mode: str,
10281032
flags: int = ...,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.