mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
Make redirect_std{out,err} yield new stream as context var (#4285)
This matches the implementation, even though this behaviour isn't actually documented yet. https://bugs.python.org/issue41147 aims to fix the documentation issue though. Fixes https://github.com/python/typeshed/issues/4283.
This commit is contained in:
@@ -16,6 +16,7 @@ if sys.version_info >= (3, 7):
|
||||
from typing import AsyncContextManager as AbstractAsyncContextManager
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_T_io = TypeVar('_T_io', bound=Optional[IO[str]])
|
||||
_F = TypeVar('_F', bound=Callable[..., Any])
|
||||
|
||||
_ExitFunc = Callable[[Optional[Type[BaseException]],
|
||||
@@ -48,12 +49,12 @@ if sys.version_info >= (3, 4):
|
||||
excinst: Optional[BaseException],
|
||||
exctb: Optional[TracebackType]) -> bool: ...
|
||||
|
||||
class redirect_stdout(ContextManager[None]):
|
||||
def __init__(self, new_target: Optional[IO[str]]) -> None: ...
|
||||
class redirect_stdout(ContextManager[_T_io]):
|
||||
def __init__(self, new_target: _T_io) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 5):
|
||||
class redirect_stderr(ContextManager[None]):
|
||||
def __init__(self, new_target: Optional[IO[str]]) -> None: ...
|
||||
class redirect_stderr(ContextManager[_T_io]):
|
||||
def __init__(self, new_target: _T_io) -> None: ...
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
class ContextDecorator:
|
||||
|
||||
Reference in New Issue
Block a user