Skip to content

Commit 1dd4064

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 65c5c03 commit 1dd4064

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

mypy/dmypy_server.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import traceback
1919
from collections.abc import Sequence, Set as AbstractSet
2020
from contextlib import redirect_stderr, redirect_stdout
21-
from typing import Any, Callable, Final, Literal, cast
21+
from typing import Any, Callable, Final
2222
from typing_extensions import TypeAlias as _TypeAlias
2323

2424
import mypy.build
@@ -203,9 +203,11 @@ def __init__(self, options: Options, status_file: str, timeout: int | None = Non
203203
# Since the object is created in the parent process we can check
204204
# the output terminal options here.
205205
self.formatter = FancyFormatter(
206-
sys.stdout, sys.stderr, options.hide_error_codes,
206+
sys.stdout,
207+
sys.stderr,
208+
options.hide_error_codes,
207209
color_request=util.should_force_color() or options.color_output is not False,
208-
warn_color_fail=options.warn_color_fail
210+
warn_color_fail=options.warn_color_fail,
209211
)
210212

211213
def _response_metadata(self) -> dict[str, str]:

mypy/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from collections.abc import Sequence
1212
from gettext import gettext
1313
from io import TextIOWrapper
14-
from typing import IO, TYPE_CHECKING, Any, Final, Literal, NoReturn, TextIO, cast
14+
from typing import IO, TYPE_CHECKING, Any, Final, NoReturn, TextIO
1515

1616
from mypy import build, defaults, state, util
1717
from mypy.config_parser import (
@@ -101,9 +101,9 @@ def main(
101101

102102
# Type annotation needed for mypy (Pyright understands this)
103103
use_color: bool = (
104-
True if util.should_force_color() or options.color_output == "force"
105-
else formatter.default_colored if options.color_output is True
106-
else False
104+
True
105+
if util.should_force_color() or options.color_output == "force"
106+
else formatter.default_colored if options.color_output is True else False
107107
)
108108

109109
if options.allow_redefinition_new and not options.local_partial_types:

mypy/test/test_color_output.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
from functools import partial
21
import subprocess
3-
from typing import TYPE_CHECKING, Any
42
import sys
3+
from typing import TYPE_CHECKING
4+
55
import pytest
66

7-
#XXX Would like help with this test, how do I make it runnable?
7+
# XXX Would like help with this test, how do I make it runnable?
88
# Haven't run this test yet
99

1010
PTY_SIZE = (80, 40)
1111

1212
if sys.platform == "win32":
1313
if TYPE_CHECKING:
1414
# This helps my IDE find the type annotations
15-
from winpty.winpty import PTY #type:ignore[import-untyped]
15+
from winpty.winpty import PTY # type:ignore[import-untyped]
1616
else:
1717
from winpty import PTY
1818

@@ -24,6 +24,7 @@ def run_pty(cmd: str, env: dict[str, str] = {}) -> tuple[str, str]:
2424
while pty.isalive():
2525
pass
2626
return pty.read(), pty.read_stderr()
27+
2728
elif sys.platform == "unix":
2829
from pty import openpty
2930

@@ -38,6 +39,8 @@ def run_pty(cmd: str, env: dict[str, str] = {}) -> tuple[str, str]:
3839
return os.read(slave_fd, 10000).decode(), p.stderr
3940
finally:
4041
os.close(master_fd)
42+
43+
4144
def test(expect_color: bool, pty: bool, cmd: str, env: dict[str, str] = {}) -> None:
4245
if pty:
4346
stdout, stderr = run_pty(cmd, env=env)
@@ -58,6 +61,7 @@ def test(expect_color: bool, pty: bool, cmd: str, env: dict[str, str] = {}) -> N
5861
def test_pty(expect_color: bool, cmd: str, env: dict[str, str] = {}) -> None:
5962
test(expect_color, True, cmd, env)
6063

64+
6165
def test_not_pty(expect_color: bool, cmd: str, env: dict[str, str] = {}) -> None:
6266
test(expect_color, False, cmd, env)
6367

test-requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ pytest-cov>=2.10.0
1313
setuptools>=75.1.0
1414
tomli>=1.1.0 # needed even on py311+ so the self check passes with --python-version 3.9
1515
pre_commit>=3.5.0
16-
pywinpty; sys_platform == 'win32'
16+
pywinpty; sys_platform == 'win32'

0 commit comments

Comments
 (0)