From b2997fe11035d76fdef089442163e6451ad30ce7 Mon Sep 17 00:00:00 2001 From: Dibri Nsofor Date: Mon, 4 Nov 2024 14:02:33 -0700 Subject: [PATCH 1/8] added flag for plugin args Signed-off-by: Dibri Nsofor --- mypy/main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mypy/main.py b/mypy/main.py index ae3e7d75be7f..497daa734a25 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -1003,6 +1003,12 @@ def add_invertible_flag( action="store_true", help="Skip cache internal consistency checks based on mtime", ) + incremental_group.add_argument( + "--plugins", + nargs='*', + dest="special-opts:cli_plugins", + help="Include user defined plugins during Mypy's type analysis", + ) internals_group = parser.add_argument_group( title="Advanced options", description="Debug and customize mypy internals." @@ -1291,6 +1297,10 @@ def set_strict_flags() -> None: special_opts = argparse.Namespace() parser.parse_args(args, SplitNamespace(options, special_opts, "special-opts:")) + # Parse extra plugins passed via cli args + if special_opts.cli_plugins: + options.plugins.extend(special_opts.cli_plugins) + # The python_version is either the default, which can be overridden via a config file, # or stored in special_opts and is passed via the command line. options.python_version = special_opts.python_version or options.python_version From 021cb65b3abf16b7aa1c24778bd9db5db7a8239a Mon Sep 17 00:00:00 2001 From: Dibri Nsofor Date: Mon, 4 Nov 2024 14:12:54 -0700 Subject: [PATCH 2/8] reformat string literal Signed-off-by: Dibri Nsofor --- mypy/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/main.py b/mypy/main.py index 497daa734a25..a3402d438f8c 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -1005,7 +1005,7 @@ def add_invertible_flag( ) incremental_group.add_argument( "--plugins", - nargs='*', + nargs="*", dest="special-opts:cli_plugins", help="Include user defined plugins during Mypy's type analysis", ) From 79092dd58536c5ea252110d239245453a9b019f6 Mon Sep 17 00:00:00 2001 From: Dibri Nsofor Date: Mon, 4 Nov 2024 14:36:56 -0700 Subject: [PATCH 3/8] updated docs Signed-off-by: Dibri Nsofor --- docs/source/command_line.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index 92db5d59d0ee..1e80ae7e9527 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -888,6 +888,11 @@ in developing or debugging mypy internals. This flag will invoke the Python debugger when mypy encounters a fatal error. +.. option:: --plugins {MODULE|PLUGIN_FILE} ... + + This flag acts as a supplementary way to pass (a list of) plugins to customize + Mypy's type checking approach. See :ref:`extending-mypy` for more details. + .. option:: --show-traceback, --tb If set, this flag will display a full traceback when mypy From f57dcde69e74002eb4c7ff2d66fc171a70d79f81 Mon Sep 17 00:00:00 2001 From: Dibri Nsofor Date: Mon, 4 Nov 2024 14:42:18 -0700 Subject: [PATCH 4/8] moved logic to internals Signed-off-by: Dibri Nsofor --- mypy/main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mypy/main.py b/mypy/main.py index a3402d438f8c..89f7d90e7998 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -1003,17 +1003,17 @@ def add_invertible_flag( action="store_true", help="Skip cache internal consistency checks based on mtime", ) - incremental_group.add_argument( - "--plugins", - nargs="*", - dest="special-opts:cli_plugins", - help="Include user defined plugins during Mypy's type analysis", - ) internals_group = parser.add_argument_group( title="Advanced options", description="Debug and customize mypy internals." ) internals_group.add_argument("--pdb", action="store_true", help="Invoke pdb on fatal error") + internals_group.add_argument( + "--plugins", + nargs="*", + dest="special-opts:cli_plugins", + help="Include user defined plugins during Mypy's type analysis", + ) internals_group.add_argument( "--show-traceback", "--tb", action="store_true", help="Show traceback on fatal error" ) From 9ff5c41e68a7addc45d321f74e5ac8cd62f219d5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 21:43:47 +0000 Subject: [PATCH 5/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 1e80ae7e9527..3060cbda2417 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -890,7 +890,7 @@ in developing or debugging mypy internals. .. option:: --plugins {MODULE|PLUGIN_FILE} ... - This flag acts as a supplementary way to pass (a list of) plugins to customize + This flag acts as a supplementary way to pass (a list of) plugins to customize Mypy's type checking approach. See :ref:`extending-mypy` for more details. .. option:: --show-traceback, --tb From 9e305daa5193390ee3c400d3e8d1dbfb4496d1ee Mon Sep 17 00:00:00 2001 From: Dibri Nsofor Date: Mon, 4 Nov 2024 16:01:34 -0700 Subject: [PATCH 6/8] renamed flag, updated docs, rewrote logic -- replaced nargs with str opt Signed-off-by: Dibri Nsofor --- docs/source/command_line.rst | 2 +- mypy/main.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index 1e80ae7e9527..0f4b963ea41f 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -888,7 +888,7 @@ in developing or debugging mypy internals. This flag will invoke the Python debugger when mypy encounters a fatal error. -.. option:: --plugins {MODULE|PLUGIN_FILE} ... +.. option:: --extend-plugins {MODULE|PLUGIN_FILE} ... This flag acts as a supplementary way to pass (a list of) plugins to customize Mypy's type checking approach. See :ref:`extending-mypy` for more details. diff --git a/mypy/main.py b/mypy/main.py index 89f7d90e7998..2844c6c52290 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -1009,8 +1009,9 @@ def add_invertible_flag( ) internals_group.add_argument("--pdb", action="store_true", help="Invoke pdb on fatal error") internals_group.add_argument( - "--plugins", - nargs="*", + "--extend-plugins", "--ep", + type=lambda s: [item.strip() for item in s.split(',')], + metavar="{MODULE|PLUGIN_FILE}", dest="special-opts:cli_plugins", help="Include user defined plugins during Mypy's type analysis", ) @@ -1300,6 +1301,7 @@ def set_strict_flags() -> None: # Parse extra plugins passed via cli args if special_opts.cli_plugins: options.plugins.extend(special_opts.cli_plugins) + print(special_opts.cli_plugins) # The python_version is either the default, which can be overridden via a config file, # or stored in special_opts and is passed via the command line. From 8c7db13f71098a6facea66ab165b6bc3ef688bdf Mon Sep 17 00:00:00 2001 From: Dibri Nsofor Date: Mon, 4 Nov 2024 16:10:48 -0700 Subject: [PATCH 7/8] shorter flag Signed-off-by: Dibri Nsofor --- 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 4b4c60cd2e73..82f399b5264b 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -888,7 +888,7 @@ in developing or debugging mypy internals. This flag will invoke the Python debugger when mypy encounters a fatal error. -.. option:: --extend-plugins {MODULE|PLUGIN_FILE} ... +.. option:: --extend-plugins, --ep {MODULE|PLUGIN_FILE} ... This flag acts as a supplementary way to pass (a list of) plugins to customize Mypy's type checking approach. See :ref:`extending-mypy` for more details. From 74da5c640de2875a0b1e971d294d40e75ba862ea Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 23:11:34 +0000 Subject: [PATCH 8/8] [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, 3 insertions(+), 2 deletions(-) diff --git a/mypy/main.py b/mypy/main.py index 2844c6c52290..f39cf08022c1 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -1009,8 +1009,9 @@ def add_invertible_flag( ) internals_group.add_argument("--pdb", action="store_true", help="Invoke pdb on fatal error") internals_group.add_argument( - "--extend-plugins", "--ep", - type=lambda s: [item.strip() for item in s.split(',')], + "--extend-plugins", + "--ep", + type=lambda s: [item.strip() for item in s.split(",")], metavar="{MODULE|PLUGIN_FILE}", dest="special-opts:cli_plugins", help="Include user defined plugins during Mypy's type analysis",