Skip to content

Commit 04563b6

Browse files
committed
feat: Enable --pretty by default.
Change the default mypy output to be pretty-printed, providing users with more readable error messages that include code context out-of-the-box. This commit implements the core logic for this feature: - In 'mypy/options.py', the default value for 'pretty' is set to 'True'. - In 'mypy/main.py', the command-line flags are reconfigured: - '--no-pretty' is now the primary, user-facing flag to disable the pretty printing. - The old '--pretty' flag is deprecated and hidden from help text to reflect that the pretty output is now default. This change intentionally breaks the test suite, which will be fixediIn subsequent commits by adapting the test runners. Part of python#19108
1 parent d528707 commit 04563b6

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

‎mypy/main.py‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -991,14 +991,6 @@ def add_invertible_flag(
991991
help="Show links to error code documentation",
992992
group=error_group,
993993
)
994-
add_invertible_flag(
995-
"--pretty",
996-
default=False,
997-
help="Use visually nicer output in error messages:"
998-
" Use soft word wrap, show source code snippets,"
999-
" and show error location markers",
1000-
group=error_group,
1001-
)
1002994
add_invertible_flag(
1003995
"--no-color-output",
1004996
dest="color_output",
@@ -1026,6 +1018,18 @@ def add_invertible_flag(
10261018
dest="many_errors_threshold",
10271019
help=argparse.SUPPRESS,
10281020
)
1021+
error_group.add_argument(
1022+
'--no-pretty',
1023+
action='store_false',
1024+
dest='pretty',
1025+
help='Disable pretty error messages (pretty is now the default).'
1026+
)
1027+
error_group.add_argument(
1028+
'--pretty',
1029+
action='store_true',
1030+
dest='pretty',
1031+
help=argparse.SUPPRESS
1032+
)
10291033

10301034
incremental_group = parser.add_argument_group(
10311035
title="Incremental mode",

‎mypy/options.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def __init__(self) -> None:
357357
self.hide_error_codes = False
358358
self.show_error_code_links = False
359359
# Use soft word wrap and show trimmed source snippets with error location markers.
360-
self.pretty = False
360+
self.pretty = True
361361
self.dump_graph = False
362362
self.dump_deps = False
363363
self.logical_deps = False

0 commit comments

Comments
 (0)