Skip to content

Commit c9c4459

Browse files
committed
Fix mypy issues
1 parent ba7af9c commit c9c4459

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/prompt_toolkit/output/defaults.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def create_output(
4545
if stdout is None:
4646
# By default, render to stdout. If the output is piped somewhere else,
4747
# render to stderr.
48-
stdout = sys.stdout
48+
stdout = sys.__stdout__
4949

5050
if always_prefer_tty:
5151
for io in [sys.stdout, sys.stderr]:
@@ -54,13 +54,6 @@ def create_output(
5454
stdout = io
5555
break
5656

57-
# If the output is still `None`, use a DummyOutput.
58-
# This happens for instance on Windows, when running the application under
59-
# `pythonw.exe`. In that case, there won't be a terminal Window, and
60-
# stdin/stdout/stderr are `None`.
61-
if stdout is None:
62-
return DummyOutput()
63-
6457
# If the patch_stdout context manager has been used, then sys.stdout is
6558
# replaced by this proxy. For prompt_toolkit applications, we want to use
6659
# the real stdout.
@@ -69,6 +62,13 @@ def create_output(
6962
while isinstance(stdout, StdoutProxy):
7063
stdout = stdout.original_stdout
7164

65+
# If the output is still `None`, use a DummyOutput.
66+
# This happens for instance on Windows, when running the application under
67+
# `pythonw.exe`. In that case, there won't be a terminal Window, and
68+
# stdin/stdout/stderr are `None`.
69+
if stdout is None:
70+
return DummyOutput()
71+
7272
if sys.platform == "win32":
7373
from .conemu import ConEmuOutput
7474
from .win32 import Win32Output

src/prompt_toolkit/patch_stdout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ def flush(self) -> None:
273273
self._flush()
274274

275275
@property
276-
def original_stdout(self) -> TextIO:
277-
return self._output.stdout or sys.__stdout__
276+
def original_stdout(self) -> TextIO | None:
277+
return None # self._output.stdout or sys.__stdout__
278278

279279
# Attributes for compatibility with sys.__stdout__:
280280

0 commit comments

Comments
 (0)