Skip to content
Open
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
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ Configuration
- ``array`` of (``string`` items or ``true``)
- **A list of alternate or supplemental command-line options**. This modifies the options passed to ``mypy`` or the mypy-specific ones passed to ``dmypy run``. When present, the special boolean member ``true`` is replaced with the command-line options that would've been passed had ``overrides`` not been specified.
- ``[true]``
* - ``dmypy_log_file``
- ``pylsp.plugins.pylsp_mypy.dmypy_log_file``
- ``string``
- **Specifies a path for dmypy logs**. This modifies the ``--log-file`` option passed to ``dmypy`` given ``dmypy`` is active.
- ``None``
* - ``dmypy_status_file``
- ``pylsp.plugins.pylsp_mypy.dmypy_status_file``
- ``string``
Expand Down
14 changes: 9 additions & 5 deletions pylsp_mypy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ def get_diagnostics(
live_mode = False

if dmypy:
dmypy_log_file = settings.get("dmypy_log_file")
dmypy_status_file = settings.get("dmypy_status_file", ".dmypy.json")

args = ["--show-error-end", "--no-error-summary", "--no-pretty"]
Expand Down Expand Up @@ -404,13 +405,16 @@ def get_diagnostics(
mypy_api.run_dmypy(["--status-file", dmypy_status_file, "restart"])

# run to use existing daemon or restart if required
args = ["--status-file", dmypy_status_file, "run", "--"] + apply_overrides(args, overrides)
runargs = ["--status-file", dmypy_status_file, "run"]
if dmypy_log_file is not None:
runargs += ["--log-file", dmypy_log_file]
runargs += ["--"] + apply_overrides(args, overrides)
if dmypy_command:
# dmypy exists on PATH or was provided by settings
# -> use this dmypy
log.info("dmypy run args = %s via path", args)
log.info("dmypy run args = %s via path", runargs)
completed_process = subprocess.run(
[*dmypy_command, *args], capture_output=True, **windows_flag, encoding="utf-8"
[*dmypy_command, *runargs], capture_output=True, **windows_flag, encoding="utf-8"
)
report = completed_process.stdout
errors = completed_process.stderr
Expand All @@ -419,8 +423,8 @@ def get_diagnostics(
# dmypy does not exist on PATH and was not provided by settings,
# but must exist in the env pylsp-mypy is installed in
# -> use dmypy via api
log.info("dmypy run args = %s via api", args)
report, errors, exit_status = mypy_api.run_dmypy(args)
log.info("dmypy run args = %s via api", runargs)
report, errors, exit_status = mypy_api.run_dmypy(runargs)

log.debug("report:\n%s", report)
log.debug("errors:\n%s", errors)
Expand Down
Loading