Skip to content

Commit f08e730

Browse files
be a little more consistent with stdout and stderr optional arguments
1 parent 660d911 commit f08e730

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

mypy/build.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ def _build(
210210
alt_lib_path: str | None,
211211
flush_errors: Callable[[str | None, list[str], bool], None],
212212
fscache: FileSystemCache | None,
213-
stdout: TextIO,
214-
stderr: TextIO,
213+
stdout: TextIO | None,
214+
stderr: TextIO | None,
215215
extra_plugins: Sequence[Plugin],
216216
) -> BuildResult:
217217
if platform.python_implementation() == "CPython":
@@ -398,7 +398,7 @@ def import_priority(imp: ImportBase, toplevel_priority: int) -> int:
398398

399399

400400
def load_plugins_from_config(
401-
options: Options, errors: Errors, stdout: TextIO
401+
options: Options, errors: Errors, stdout: TextIO|None
402402
) -> tuple[list[Plugin], dict[str, str]]:
403403
"""Load all configured plugins.
404404
@@ -490,7 +490,7 @@ def plugin_error(message: str) -> NoReturn:
490490

491491

492492
def load_plugins(
493-
options: Options, errors: Errors, stdout: TextIO, extra_plugins: Sequence[Plugin]
493+
options: Options, errors: Errors, stdout: TextIO|None, extra_plugins: Sequence[Plugin]
494494
) -> tuple[Plugin, dict[str, str]]:
495495
"""Load all configured plugins.
496496
@@ -606,8 +606,8 @@ def __init__(
606606
errors: Errors,
607607
flush_errors: Callable[[str | None, list[str], bool], None],
608608
fscache: FileSystemCache,
609-
stdout: TextIO,
610-
stderr: TextIO,
609+
stdout: TextIO | None,
610+
stderr: TextIO | None,
611611
error_formatter: ErrorFormatter | None = None,
612612
) -> None:
613613
self.stats: dict[str, Any] = {} # Values are ints or floats
@@ -1075,7 +1075,7 @@ def read_plugins_snapshot(manager: BuildManager) -> dict[str, str] | None:
10751075

10761076

10771077
def read_quickstart_file(
1078-
options: Options, stdout: TextIO
1078+
options: Options, stdout: TextIO | None
10791079
) -> dict[str, tuple[float, int, str]] | None:
10801080
quickstart: dict[str, tuple[float, int, str]] | None = None
10811081
if options.quickstart_file:
@@ -2879,7 +2879,7 @@ def log_configuration(manager: BuildManager, sources: list[BuildSource]) -> None
28792879
# The driver
28802880

28812881

2882-
def dispatch(sources: list[BuildSource], manager: BuildManager, stdout: TextIO) -> Graph:
2882+
def dispatch(sources: list[BuildSource], manager: BuildManager, stdout: TextIO | None) -> Graph:
28832883
log_configuration(manager, sources)
28842884

28852885
t0 = time.time()

mypy/config_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ def parse_section(
497497
set_strict_flags: Callable[[], None],
498498
section: Mapping[str, Any],
499499
config_types: dict[str, Any],
500-
stderr: TextIO = sys.stderr,
500+
stderr: TextIO | None,
501501
) -> tuple[dict[str, object], dict[str, str]]:
502502
"""Parse one section of a config file.
503503

mypy/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ def __call__(
465465
def define_options(
466466
program: str = "mypy",
467467
header: str = HEADER,
468-
stdout: TextIO = sys.stdout,
469-
stderr: TextIO = sys.stderr,
468+
stdout: TextIO | None,
469+
stderr: TextIO | None,
470470
server_options: bool = False,
471471
) -> tuple[CapturableArgumentParser, list[str], list[tuple[str, bool]]]:
472472
"""Define the options in the parser (by calling a bunch of methods that express/build our desired command-line flags).
@@ -1634,9 +1634,9 @@ def maybe_write_junit_xml(
16341634
)
16351635

16361636

1637-
def fail(msg: str, stderr: TextIO, options: Options) -> NoReturn:
1637+
def fail(msg: str, stderr: TextIO | None, options: Options) -> NoReturn:
16381638
"""Fail with a serious error."""
1639-
stderr.write(f"{msg}\n")
1639+
print(msg, file=stderr)
16401640
maybe_write_junit_xml(
16411641
0.0, serious=True, all_messages=[msg], messages_by_file={None: [msg]}, options=options
16421642
)

0 commit comments

Comments
 (0)