Closed Jasha10 closed 1 year ago
One might think that the overrides
key in the .pylsp-mypy.cfg
could handle this use-case, but it does not, because the overrides are not consistently applied for all calls to dmypy.
For example, the calls mypy_api.run_dmypy(["status"])
and mypy_api.run_dmypy(["kill"])
in this plugin's pylsp_lint
function do not take into account the overrides.
The --status-file
argument would need to be passed in consistently across all calls to dmypy.
So passing the overrides consistently would also resolve this?
I do not think the overrides should be passed consistently.
Overrides that work with dmypy run -- src
will not always work with dmypy status
and dmypy kill
. For example, dmypy run -- src --check-untyped-defs
makes sense but dmypy kill --check-untyped-defs
does not make sense.
Also, the --status-file
flag needs to be passed to dmypy
before the status
or kill
or run
argument:
dmypy --status-file=foo run -- src # this works
dmypy run --status-file=foo -- src # this fails with an error
dmypy run -- src --status-file=foo # this fails with an error
We would need to implement a separate dmypy_overrides
configuration parameter that gets always passed to dmypy
calls, even when the more general overrides
parameter does not apply.
...
# passing dmypy_overrides only:
mypy_api.run_dmypy([*dmypy_overrides, "status"])
...
# killing the daemon:
mypy_api.run_dmypy([*dmypy_overrides, "kill"])
...
# passing both dmypy_overrides and normal args+overrides:
mypy_api.run_dmypy([*dmypy_overrides, "run", "--", *run_args])
@Richardk2n I'd be happy to open a PR implementing dmypy_overrides
.
Are there such overrides other than the status file that are relevant and are passed in this matter?
(asking for if we should implement and overrides dict or just the flag)
Good question. After looking through the other dmypy flags (here's a full list), I think only the --status-file
flag makes sense to pass in this manner.
--log-file
flag could be passed in this manner, but --log-file
controls the destination of stdout/stderr. Passing --log-file
via pylsp-mypy doesn't make sense since pylsp-mypy already handles dmypy's output streams itself.--status-file
and --log-file
) appear to be supported by only a subset of the dmypy commands, e.g. the --timeout
flag only works with dmypy start
/ dmypy restart
/ dmypy run
. This means e.g. applying --timeout=10
to dmypy kill
or dmypy status
wouldn't make sense. Thus --timeout
would not work with an overrides dict.
Hello,
I'd like to request support for setting the dmypy
--status-file
flag via thepylsp-mypy.cfg
file.The use case is to ensure that multiple instances of the dmypy server do not collide with eachother.
Desired behavior:
Setting e.g.
"dmypy_status_file": ".dmypy-pylsp.json"
in thepylsp-mypy.cfg
file should cause this plugin's invocations ofdmypy
to pass an argument--status-file=.dmypy-pylsp.json
.