mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
Add missing metaclasses in ast and contextlib (#8497)
This commit is contained in:
@@ -5,21 +5,25 @@ from typing import Any, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class Num(Constant):
|
||||
class _ABC(type):
|
||||
if sys.version_info >= (3, 9):
|
||||
def __init__(cls, *args: object) -> None: ...
|
||||
|
||||
class Num(Constant, metaclass=_ABC):
|
||||
value: complex
|
||||
|
||||
class Str(Constant):
|
||||
class Str(Constant, metaclass=_ABC):
|
||||
value: str
|
||||
# Aliases for value, for backwards compatibility
|
||||
s: str
|
||||
|
||||
class Bytes(Constant):
|
||||
class Bytes(Constant, metaclass=_ABC):
|
||||
value: bytes
|
||||
# Aliases for value, for backwards compatibility
|
||||
s: bytes
|
||||
|
||||
class NameConstant(Constant): ...
|
||||
class Ellipsis(Constant): ...
|
||||
class NameConstant(Constant, metaclass=_ABC): ...
|
||||
class Ellipsis(Constant, metaclass=_ABC): ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
class slice(AST): ...
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import abc
|
||||
import sys
|
||||
from _typeshed import Self, StrOrBytesPath
|
||||
from abc import abstractmethod
|
||||
@@ -133,7 +134,9 @@ class _RedirectStream(AbstractContextManager[_T_io]):
|
||||
class redirect_stdout(_RedirectStream[_T_io]): ...
|
||||
class redirect_stderr(_RedirectStream[_T_io]): ...
|
||||
|
||||
class ExitStack:
|
||||
# In reality this is a subclass of `AbstractContextManager`;
|
||||
# see #7961 for why we don't do that in the stub
|
||||
class ExitStack(metaclass=abc.ABCMeta):
|
||||
def __init__(self) -> None: ...
|
||||
def enter_context(self, cm: AbstractContextManager[_T]) -> _T: ...
|
||||
def push(self, exit: _CM_EF) -> _CM_EF: ...
|
||||
@@ -148,7 +151,9 @@ class ExitStack:
|
||||
_ExitCoroFunc: TypeAlias = Callable[[type[BaseException] | None, BaseException | None, TracebackType | None], Awaitable[bool]]
|
||||
_ACM_EF = TypeVar("_ACM_EF", bound=AbstractAsyncContextManager[Any] | _ExitCoroFunc)
|
||||
|
||||
class AsyncExitStack:
|
||||
# In reality this is a subclass of `AbstractAsyncContextManager`;
|
||||
# see #7961 for why we don't do that in the stub
|
||||
class AsyncExitStack(metaclass=abc.ABCMeta):
|
||||
def __init__(self) -> None: ...
|
||||
def enter_context(self, cm: AbstractContextManager[_T]) -> _T: ...
|
||||
async def enter_async_context(self, cm: AbstractAsyncContextManager[_T]) -> _T: ...
|
||||
|
||||
Reference in New Issue
Block a user