Skip to content

Commit

Permalink
Merge pull request tomv564#48 from syphar/progress-reports
Browse files Browse the repository at this point in the history
add simple progress reporting
  • Loading branch information
Richardk2n authored Jan 5, 2023
2 parents 4de3d2d + 33087a2 commit 8ab82ea
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
12 changes: 12 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Configuration
``config_sub_paths`` (default is ``[]``) specifies sub paths under which the mypy configuration file may be found.
For each directory searched for the mypy config file, this also searches the sub paths specified here

``report_progress`` (default is ``False``) report basic progress to the LSP client.
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.

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:

::
Expand Down Expand Up @@ -103,6 +106,15 @@ With ``config_sub_paths`` your config could look like this:
"config_sub_paths": [".config"]
}

With ``report_progress`` your config could look like this:

::

{
"enabled": True,
"report_progress": True
}

Developing
-------------

Expand Down
36 changes: 35 additions & 1 deletion pylsp_mypy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def pylsp_lint(
config: Config, workspace: Workspace, document: Document, is_saved: bool
) -> List[Dict[str, Any]]:
"""
Lints.
Call the linter.
Parameters
----------
Expand Down Expand Up @@ -157,6 +157,40 @@ def pylsp_lint(
if settings == {}:
settings = oldSettings2

if settings.get("report_progress", False):
with workspace.report_progress("lint: mypy"):
return get_diagnostics(config, workspace, document, settings, is_saved)
else:
return get_diagnostics(config, workspace, document, settings, is_saved)


def get_diagnostics(
config: Config,
workspace: Workspace,
document: Document,
settings: Dict[str, Any],
is_saved: bool,
) -> List[Dict[str, Any]]:
"""
Lints.
Parameters
----------
config : Config
The pylsp config.
workspace : Workspace
The pylsp workspace.
document : Document
The document to be linted.
is_saved : bool
Weather the document is saved.
Returns
-------
List[Dict[str, Any]]
List of the linting data.
"""
log.info(
"lint settings = %s document.path = %s is_saved = %s",
settings,
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ classifiers =
python_requires = >= 3.7
packages = find:
install_requires =
python-lsp-server
python-lsp-server >=1.7.0
mypy
toml

Expand Down

0 comments on commit 8ab82ea

Please sign in to comment.