|
11 | 11 | from collections.abc import Sequence
|
12 | 12 | from gettext import gettext
|
13 | 13 | from io import TextIOWrapper
|
14 |
| -from typing import IO, Any, Final, NoReturn, Protocol, TextIO |
| 14 | +from typing import IO, TYPE_CHECKING, Any, Final, NoReturn, TextIO |
15 | 15 |
|
16 | 16 | from mypy import build, defaults, state, util
|
17 | 17 | from mypy.config_parser import (
|
|
36 | 36 | from mypy.split_namespace import SplitNamespace
|
37 | 37 | from mypy.version import __version__
|
38 | 38 |
|
39 |
| - |
40 |
| -class _SupportsWrite(Protocol): |
41 |
| - def write(self, s: str, /) -> object: ... |
| 39 | +if TYPE_CHECKING: |
| 40 | + from _typeshed import SupportsWrite |
42 | 41 |
|
43 | 42 |
|
44 | 43 | orig_stat: Final = os.stat
|
@@ -378,17 +377,17 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
|
378 | 377 | # =====================
|
379 | 378 | # Help-printing methods
|
380 | 379 | # =====================
|
381 |
| - def print_usage(self, file: _SupportsWrite | None = None) -> None: |
| 380 | + def print_usage(self, file: SupportsWrite[str] | None = None) -> None: |
382 | 381 | if file is None:
|
383 | 382 | file = self.stdout
|
384 | 383 | self._print_message(self.format_usage(), file)
|
385 | 384 |
|
386 |
| - def print_help(self, file: _SupportsWrite | None = None) -> None: |
| 385 | + def print_help(self, file: SupportsWrite[str] | None = None) -> None: |
387 | 386 | if file is None:
|
388 | 387 | file = self.stdout
|
389 | 388 | self._print_message(self.format_help(), file)
|
390 | 389 |
|
391 |
| - def _print_message(self, message: str, file: _SupportsWrite | None = None) -> None: |
| 390 | + def _print_message(self, message: str, file: SupportsWrite[str] | None = None) -> None: |
392 | 391 | if message:
|
393 | 392 | if file is None:
|
394 | 393 | file = self.stderr
|
|
0 commit comments