Skip to content

add simple progress reporting #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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