Add @final to several more stdlib classes (#7215)

Co-authored-by: hauntsaninja <>
This commit is contained in:
Shantanu
2022-02-14 15:12:40 -08:00
committed by GitHub
parent a67c316d08
commit a6d9b83263
6 changed files with 13 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
import sys
from _typeshed import SupportsRead
from typing import IO, Any, NamedTuple, Union, overload
from typing_extensions import final
if sys.platform != "win32":
_chtype = Union[str, bytes, int]
@@ -374,6 +375,7 @@ if sys.platform != "win32":
class error(Exception): ...
@final
class _CursesWindow:
encoding: str
@overload

View File

@@ -1,6 +1,7 @@
from _typeshed import StrOrBytesPath
from types import CodeType
from typing import Any, Sequence
from typing_extensions import final
def expr(source: str) -> STType: ...
def suite(source: str) -> STType: ...
@@ -14,6 +15,7 @@ def issuite(st: STType) -> bool: ...
class ParserError(Exception): ...
@final
class STType:
def compile(self, filename: StrOrBytesPath = ...) -> CodeType: ...
def isexpr(self) -> bool: ...

View File

@@ -2,6 +2,7 @@ import sys
from _typeshed import FileDescriptorLike, Self
from types import TracebackType
from typing import Any, Iterable
from typing_extensions import final
if sys.platform != "win32":
PIPE_BUF: int
@@ -33,6 +34,7 @@ error = OSError
if sys.platform != "linux" and sys.platform != "win32":
# BSD only
@final
class kevent:
data: Any
fflags: int
@@ -50,6 +52,7 @@ if sys.platform != "linux" and sys.platform != "win32":
udata: Any = ...,
) -> None: ...
# BSD only
@final
class kqueue:
closed: bool
def __init__(self) -> None: ...

View File

@@ -13,6 +13,7 @@ if sys.version_info >= (3, 9):
Any = object()
@_final
class TypeVar:
__name__: str
__bound__: Any | None
@@ -30,6 +31,7 @@ class TypeVar:
_promote = object()
# N.B. Keep this definition in sync with typing_extensions._SpecialForm
@_final
class _SpecialForm:
def __getitem__(self, typeargs: Any) -> object: ...
if sys.version_info >= (3, 10):
@@ -748,6 +750,7 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
def type_check_only(func_or_cls: _F) -> _F: ...
if sys.version_info >= (3, 7):
@_final
class ForwardRef:
__forward_arg__: str
__forward_code__: CodeType

View File

@@ -150,6 +150,7 @@ NotRequired: _SpecialForm
LiteralString: _SpecialForm
Unpack: _SpecialForm
@final
class TypeVarTuple:
__name__: str
def __init__(self, name: str) -> None: ...

View File

@@ -1,8 +1,10 @@
import sys
from typing import Any
from typing_extensions import final
class Str: ...
@final
class Xxo:
def demo(self) -> None: ...