From aa2290e160f7329514b590d4f85e59ae5e35803d Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 16 Nov 2021 18:11:40 +0000 Subject: [PATCH] Fix `print` stub (#6314) --- stdlib/builtins.pyi | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 31b60db5b..895673e89 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1259,8 +1259,21 @@ def open( opener: _Opener | None = ..., ) -> IO[Any]: ... def ord(__c: str | bytes) -> int: ... + +class _SupportsWriteAndFlush(SupportsWrite[_T_contra], Protocol[_T_contra]): + def flush(self) -> None: ... + +@overload def print( - *values: object, sep: str | None = ..., end: str | None = ..., file: SupportsWrite[str] | None = ..., flush: bool = ... + *values: object, + sep: str | None = ..., + end: str | None = ..., + file: SupportsWrite[str] | None = ..., + flush: Literal[False] = ..., +) -> None: ... +@overload +def print( + *values: object, sep: str | None = ..., end: str | None = ..., file: _SupportsWriteAndFlush[str] | None = ..., flush: bool ) -> None: ... _E = TypeVar("_E", contravariant=True)