Skip to content

Commit 8ab82ea

Browse files
authored
Merge pull request #48 from syphar/progress-reports
add simple progress reporting
2 parents 4de3d2d + 33087a2 commit 8ab82ea

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

README.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ Configuration
4242
``config_sub_paths`` (default is ``[]``) specifies sub paths under which the mypy configuration file may be found.
4343
For each directory searched for the mypy config file, this also searches the sub paths specified here
4444

45+
``report_progress`` (default is ``False``) report basic progress to the LSP client.
46+
With this option, pylsp-mypy will report when mypy is running, given your editor supports LSP progress reporting. For small files this might produce annoying flashing in your editor, especially in with ``live_mode``. For large projects, enabling this can be helpful to assure yourself whether mypy is still running.
47+
4548
This project supports the use of ``pyproject.toml`` for configuration. It is in fact the preferred way. Using that your configuration could look like this:
4649

4750
::
@@ -103,6 +106,15 @@ With ``config_sub_paths`` your config could look like this:
103106
"config_sub_paths": [".config"]
104107
}
105108

109+
With ``report_progress`` your config could look like this:
110+
111+
::
112+
113+
{
114+
"enabled": True,
115+
"report_progress": True
116+
}
117+
106118
Developing
107119
-------------
108120

pylsp_mypy/plugin.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def pylsp_lint(
125125
config: Config, workspace: Workspace, document: Document, is_saved: bool
126126
) -> List[Dict[str, Any]]:
127127
"""
128-
Lints.
128+
Call the linter.
129129
130130
Parameters
131131
----------
@@ -157,6 +157,40 @@ def pylsp_lint(
157157
if settings == {}:
158158
settings = oldSettings2
159159

160+
if settings.get("report_progress", False):
161+
with workspace.report_progress("lint: mypy"):
162+
return get_diagnostics(config, workspace, document, settings, is_saved)
163+
else:
164+
return get_diagnostics(config, workspace, document, settings, is_saved)
165+
166+
167+
def get_diagnostics(
168+
config: Config,
169+
workspace: Workspace,
170+
document: Document,
171+
settings: Dict[str, Any],
172+
is_saved: bool,
173+
) -> List[Dict[str, Any]]:
174+
"""
175+
Lints.
176+
177+
Parameters
178+
----------
179+
config : Config
180+
The pylsp config.
181+
workspace : Workspace
182+
The pylsp workspace.
183+
document : Document
184+
The document to be linted.
185+
is_saved : bool
186+
Weather the document is saved.
187+
188+
Returns
189+
-------
190+
List[Dict[str, Any]]
191+
List of the linting data.
192+
193+
"""
160194
log.info(
161195
"lint settings = %s document.path = %s is_saved = %s",
162196
settings,

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ classifiers =
1919
python_requires = >= 3.7
2020
packages = find:
2121
install_requires =
22-
python-lsp-server
22+
python-lsp-server >=1.7.0
2323
mypy
2424
toml
2525

0 commit comments

Comments
 (0)