contextvars, pycurl: make classes final (#7334)

This commit is contained in:
Jelle Zijlstra
2022-02-20 16:55:48 -08:00
committed by GitHub
parent a287cfd925
commit 61361ce059
2 changed files with 8 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
import sys
from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar
from typing_extensions import ParamSpec
from typing_extensions import ParamSpec, final
if sys.version_info >= (3, 9):
from types import GenericAlias
@@ -8,6 +8,7 @@ if sys.version_info >= (3, 9):
_T = TypeVar("_T")
_P = ParamSpec("_P")
@final
class ContextVar(Generic[_T]):
def __init__(self, name: str, *, default: _T = ...) -> None: ...
@property
@@ -18,6 +19,7 @@ class ContextVar(Generic[_T]):
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
@final
class Token(Generic[_T]):
@property
def var(self) -> ContextVar[_T]: ...
@@ -31,6 +33,7 @@ def copy_context() -> Context: ...
# It doesn't make sense to make this generic, because for most Contexts each ContextVar will have
# a different value.
@final
class Context(Mapping[ContextVar[Any], Any]):
def __init__(self) -> None: ...
def run(self, callable: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> _T: ...

View File

@@ -1,6 +1,5 @@
# TODO(MichalPokorny): more precise types
from typing import Any, Text
from typing_extensions import final
GLOBAL_ACK_EINTR: int
GLOBAL_ALL: int
@@ -18,6 +17,7 @@ def version_info() -> tuple[int, str, int, str, int, str, int, str, tuple[str, .
class error(Exception): ...
@final
class Curl:
def close(self) -> None: ...
def setopt(self, option: int, value: Any) -> None: ...
@@ -34,6 +34,7 @@ class Curl:
# TODO(MichalPokorny): wat?
USERPWD: int
@final
class CurlMulti:
def close(self) -> None: ...
def add_handle(self, obj: Curl) -> None: ...
@@ -44,6 +45,7 @@ class CurlMulti:
def info_read(self, max_objects: int = ...) -> tuple[int, list[Any], list[Any]]: ...
def socket_action(self, sockfd: int, ev_bitmask: int) -> tuple[int, int]: ...
@final
class CurlShare:
def close(self) -> None: ...
def setopt(self, option: int, value: Any) -> Any: ...