Skip to content

Commit ad1a312

Browse files
committed
Update create_output signature
1 parent f43014b commit ad1a312

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/prompt_toolkit/output/defaults.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import sys
4-
from typing import TextIO, cast
4+
from typing import TYPE_CHECKING, TextIO, cast
55

66
from prompt_toolkit.utils import (
77
get_bell_environment_variable,
@@ -13,13 +13,17 @@
1313
from .color_depth import ColorDepth
1414
from .plain_text import PlainTextOutput
1515

16+
if TYPE_CHECKING:
17+
from prompt_toolkit.patch_stdout import StdoutProxy
18+
19+
1620
__all__ = [
1721
"create_output",
1822
]
1923

2024

2125
def create_output(
22-
stdout: TextIO | None = None, always_prefer_tty: bool = False
26+
stdout: TextIO | StdoutProxy | None = None, always_prefer_tty: bool = False
2327
) -> Output:
2428
"""
2529
Return an :class:`~prompt_toolkit.output.Output` instance for the command
@@ -45,7 +49,7 @@ def create_output(
4549
if stdout is None:
4650
# By default, render to stdout. If the output is piped somewhere else,
4751
# render to stderr.
48-
stdout = sys.__stdout__
52+
stdout = sys.stdout
4953

5054
if always_prefer_tty:
5155
for io in [sys.stdout, sys.stderr]:
@@ -57,8 +61,6 @@ def create_output(
5761
# If the patch_stdout context manager has been used, then sys.stdout is
5862
# replaced by this proxy. For prompt_toolkit applications, we want to use
5963
# the real stdout.
60-
from prompt_toolkit.patch_stdout import StdoutProxy
61-
6264
while isinstance(stdout, StdoutProxy):
6365
stdout = stdout.original_stdout
6466

0 commit comments

Comments
 (0)