From d07c7da9e4d0e3a79f82da6924aba870e48a450f Mon Sep 17 00:00:00 2001 From: wyattscarpenter Date: Wed, 17 Sep 2025 19:33:24 +0700 Subject: [PATCH 1/6] use raw choices. needs further tweaks --- mypy/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mypy/main.py b/mypy/main.py index b543cd33fe44e..f702ae895dbfc 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -570,7 +570,6 @@ def add_invertible_flag( general_group.add_argument( "-O", "--output", - metavar="FORMAT", help="Set a custom output format", choices=OUTPUT_CHOICES, ) @@ -1108,7 +1107,7 @@ def add_invertible_flag( parser.add_argument( "--enable-incomplete-feature", action="append", - metavar="{" + ",".join(sorted(INCOMPLETE_FEATURES)) + "}", + choices=sorted(INCOMPLETE_FEATURES), help="Enable support of incomplete/experimental features for early preview", ) internals_group.add_argument( From db50b14a0c53e00c4f99e9227da963c6be6599e2 Mon Sep 17 00:00:00 2001 From: wyattscarpenter Date: Thu, 18 Sep 2025 00:24:34 +0700 Subject: [PATCH 2/6] partial revert --- mypy/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/main.py b/mypy/main.py index f702ae895dbfc..27e3030db1224 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -1107,7 +1107,7 @@ def add_invertible_flag( parser.add_argument( "--enable-incomplete-feature", action="append", - choices=sorted(INCOMPLETE_FEATURES), + metavar="{" + ",".join(sorted(INCOMPLETE_FEATURES)) + "}", help="Enable support of incomplete/experimental features for early preview", ) internals_group.add_argument( From 80745917a16099edcfe7e9492d481dc58125c4d5 Mon Sep 17 00:00:00 2001 From: wyattscarpenter Date: Thu, 18 Sep 2025 00:32:25 +0700 Subject: [PATCH 3/6] add comment about why experimental features doesn't use choices --- mypy/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mypy/main.py b/mypy/main.py index 27e3030db1224..6cfd0e47141c3 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -1107,6 +1107,8 @@ def add_invertible_flag( parser.add_argument( "--enable-incomplete-feature", action="append", + # We can't just use choices= here because we actually accept more than this; + # see process_incomplete_features. metavar="{" + ",".join(sorted(INCOMPLETE_FEATURES)) + "}", help="Enable support of incomplete/experimental features for early preview", ) From 6b5fc1fdbb1a4dabb33cf76db9f9c43b46d21ba1 Mon Sep 17 00:00:00 2001 From: wyattscarpenter Date: Thu, 18 Sep 2025 00:36:12 +0700 Subject: [PATCH 4/6] sorted for stability --- mypy/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/main.py b/mypy/main.py index 6cfd0e47141c3..6a0148ba541ea 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -571,7 +571,7 @@ def add_invertible_flag( "-O", "--output", help="Set a custom output format", - choices=OUTPUT_CHOICES, + choices=sorted(OUTPUT_CHOICES), ) config_group = parser.add_argument_group( From 9d6cce2c1f1be2b5d2e2f77260453fd7e1788a6a Mon Sep 17 00:00:00 2001 From: wyattscarpenter Date: Thu, 18 Sep 2025 00:39:13 +0700 Subject: [PATCH 5/6] update rst to match help --- docs/source/command_line.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index c1b757a00ef20..edcb420f03c91 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -101,7 +101,7 @@ Optional arguments Show program's version number and exit. -.. option:: -O FORMAT, --output FORMAT {json} +.. option:: -O {json}, --output {json} Set a custom output format. From 4c2601a9318037cb968bdf32d9685004f7929c6e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Sep 2025 17:48:34 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mypy/main.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mypy/main.py b/mypy/main.py index 6a0148ba541ea..816e5b858b9df 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -568,10 +568,7 @@ def add_invertible_flag( ) general_group.add_argument( - "-O", - "--output", - help="Set a custom output format", - choices=sorted(OUTPUT_CHOICES), + "-O", "--output", help="Set a custom output format", choices=sorted(OUTPUT_CHOICES) ) config_group = parser.add_argument_group(