Skip to content

Commit 644a20c

Browse files
Update dmypy/client.py: Enable ANSI color codes for windows cmd (#19088)
I still use windows cmd, and the color codes emitted by dmypy do not work on there. instead printing a bunch of codes like ←[37m ←[39;49;00ms. However, for whatever reason you can fix this simply by calling os.system("") once. (The main mypy program works fine, presumably because it makes an os system call somewhere before it prints.) I did not write a test of this, as that seems difficult and unnecessary. Instead, I manually tested it, and it worked great.
1 parent a0307b5 commit 644a20c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mypy/dmypy/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,10 @@ def check_output(
562562
563563
Call sys.exit() unless the status code is zero.
564564
"""
565+
if os.name == "nt":
566+
# Enable ANSI color codes for Windows cmd using this strange workaround
567+
# ( see https://github.com/python/cpython/issues/74261 )
568+
os.system("")
565569
if "error" in response:
566570
fail(response["error"])
567571
try:

0 commit comments

Comments
 (0)