From 950e6cd2a1be32a15998c76f99f7009e53464fc4 Mon Sep 17 00:00:00 2001 From: Richard Kellnberger Date: Tue, 3 Sep 2024 18:50:38 +0200 Subject: [PATCH] configurable follow-imports --- README.rst | 5 +++++ pylsp_mypy/plugin.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 4dbb92d..f871082 100644 --- a/README.rst +++ b/README.rst @@ -73,6 +73,11 @@ Configuration - ``array`` of ``string`` items - **A list of regular expressions which should be ignored**. The ``mypy`` runner wil not be invoked when a document path is matched by one of the expressions. Note that this differs from the ``exclude`` directive of a ``mypy`` config which is only used for recursively discovering files when mypy is invoked on a whole directory. For both windows or unix platforms you should use forward slashes (``/``) to indicate paths. - ``[]`` + * - ``follow-imports`` + - ``pylsp.plugins.pylsp_mypy.follow-imports`` + - ``normal``, ``silent``, ``skip`` or ``error`` + - ``mypy`` **parameter** ``follow-imports``. In ``mypy`` this is ``normal`` by default. We set it ``silent``, to sort out unwanted results. This can cause cash invalidation if you also run ``mypy`` in other ways. Setting this to ``normal`` avoids this at the cost of a small performance penalty. + - ``silent`` Using a ``pyproject.toml`` for configuration, which is in fact the preferred way, your configuration could look like this: diff --git a/pylsp_mypy/plugin.py b/pylsp_mypy/plugin.py index bbd1f36..3ebd881 100644 --- a/pylsp_mypy/plugin.py +++ b/pylsp_mypy/plugin.py @@ -301,7 +301,7 @@ def get_diagnostics( exit_status = 0 if not dmypy: - args.extend(["--incremental", "--follow-imports", "silent"]) + args.extend(["--incremental", "--follow-imports", settings.get("follow-imports", "silent")]) args = apply_overrides(args, overrides) if shutil.which("mypy"):