Skip to content

Commit 782e1dc

Browse files
Add configuration options for the mypy pylsp plugin (#4370)
Add configuration options for the mypy pylsp plugin, documented at https://github.com/python-lsp/pylsp-mypy.
1 parent 69037e0 commit 782e1dc

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

clients/lsp-pylsp.el

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,85 @@ is present."
459459
:type 'string
460460
:group 'lsp-pylsp)
461461

462+
;; See https://github.com/python-lsp/pylsp-mypy#configuration
463+
464+
(defcustom lsp-pylsp-plugins-mypy-enabled nil
465+
"Enable or disable the plugin."
466+
:type 'boolean
467+
:group 'lsp-pylsp)
468+
469+
(defcustom lsp-pylsp-plugins-mypy-live-mode t
470+
"If non-nil, type checking is provided as you type.
471+
472+
This writes to a tempfile every time a check is done. Turning off live_mode
473+
means you must save your changes for mypy diagnostics to update correctly."
474+
:type 'boolean
475+
:group 'lsp-pylsp)
476+
477+
(defcustom lsp-pylsp-plugins-mypy-dmypy nil
478+
"If non-nil, use 'dmypy run' rather than mypy.
479+
480+
This uses the dmypy daemon and may dramatically improve the responsiveness of
481+
the pylsp server, however this currently does not work in live_mode. Enabling
482+
this disables live_mode, even for conflicting configs."
483+
:type 'boolean
484+
:group 'lsp-pylsp)
485+
486+
(defcustom lsp-pylsp-plugins-mypy-strict nil
487+
"If non-nil, enable the strict option of mypy.
488+
489+
This option often is too strict to be useful."
490+
:type 'boolean
491+
:group 'lsp-pylsp)
492+
493+
(defcustom lsp-pylsp-plugins-mypy-overrides [t]
494+
"A list of alternate or supplemental command-line options.
495+
496+
This modifies the options passed to mypy or the mypy-specific ones passed to
497+
dmypy run. When present, the special boolean member True is replaced with
498+
the command-line options that would've been passed had overrides not been
499+
specified. Later options take precedence, which allows for replacing or
500+
negating individual default options (see mypy.main:process_options and mypy
501+
--help | grep inverse)."
502+
:type '(vector (choice string boolean))
503+
:group 'lsp-pylsp)
504+
505+
(defcustom lsp-pylsp-plugins-mypy-dmypy-status-file ".dmypy.json"
506+
"The status file dmypy should use.
507+
508+
This modifies the --status-file option passed to dmypy given dmypy is active."
509+
:type 'string
510+
:group 'lsp-pylsp)
511+
512+
(defcustom lsp-pylsp-plugins-mypy-config-sub-paths nil
513+
"Sub paths under which the mypy configuration file may be found.
514+
515+
For each directory searched for the mypy config file, this also searches the
516+
sub paths specified here."
517+
:type 'lsp-string-vector
518+
:group 'lsp-pylsp)
519+
520+
(defcustom lsp-pylsp-plugins-mypy-report-progress nil
521+
"If non-nil, report basic progress to the LSP client.
522+
523+
With this option, pylsp-mypy will report when mypy is running, given your editor
524+
supports LSP progress reporting. For small files this might produce annoying
525+
flashing, especially in with live_mode. For large projects, enabling this can
526+
be helpful to assure yourself whether mypy is still running."
527+
:type 'boolean
528+
:group 'lsp-pylsp)
529+
530+
(defcustom lsp-pylsp-plugins-mypy-exclude nil
531+
"A list of regular expressions which should be ignored.
532+
533+
The mypy runner wil not be invoked when a document path is matched by one of the
534+
expressions. Note that this differs from the exclude directive of a mypy config
535+
which is only used for recursively discovering files when mypy is invoked on a
536+
whole directory. For both windows or unix platforms you should use forward
537+
slashes (/) to indicate paths."
538+
:type 'lsp-string-vector
539+
:group 'lsp-pylsp)
540+
462541
(defcustom lsp-pylsp-rename-backend 'jedi
463542
"Choose renaming backend.
464543
@@ -551,6 +630,15 @@ So it will rename only references it can find."
551630
("pylsp.plugins.ruff.perFileIgnores" lsp-pylsp-plugins-ruff-per-file-ignores)
552631
("pylsp.plugins.ruff.preview" lsp-pylsp-plugins-ruff-preview t)
553632
("pylsp.plugins.ruff.targetVersion" lsp-pylsp-plugins-ruff-target-version)
633+
("pylsp.plugins.pylsp_mypy.enabled" lsp-pylsp-plugins-mypy-enabled t)
634+
("pylsp.plugins.pylsp_mypy.live_mode" lsp-pylsp-plugins-mypy-live-mode t)
635+
("pylsp.plugins.pylsp_mypy.dmypy" lsp-pylsp-plugins-mypy-dmypy t)
636+
("pylsp.plugins.pylsp_mypy.strict" lsp-pylsp-plugins-mypy-strict t)
637+
("pylsp.plugins.pylsp_mypy.overrides" lsp-pylsp-plugins-mypy-overrides)
638+
("pylsp.plugins.pylsp_mypy.dmypy_status_file" lsp-pylsp-plugins-mypy-dmypy-status-file)
639+
("pylsp.plugins.pylsp_mypy.config_sub_paths" lsp-pylsp-plugins-mypy-config-sub-paths)
640+
("pylsp.plugins.pylsp_mypy.report_progress" lsp-pylsp-plugins-mypy-report-progress t)
641+
("pylsp.plugins.pylsp_mypy.exclude" lsp-pylsp-plugins-mypy-exclude)
554642
("pylsp.plugins.jedi_symbols.all_scopes" lsp-pylsp-plugins-jedi-symbols-all-scopes t)
555643
("pylsp.plugins.jedi_symbols.enabled" lsp-pylsp-plugins-jedi-symbols-enabled t)
556644
("pylsp.plugins.jedi_signature_help.enabled" lsp-pylsp-plugins-jedi-signature-help-enabled t)

0 commit comments

Comments
 (0)