dense-analysis / dense-analysis/ale

Support `dmypy` to speed up linting with `mypy` without too much user intervention

Open
#4,119 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

_Disclaimer:_
I'm going to structure this probably oddly because I understand the blockers here and want to be clear that I'm hoping to contribute to a discussion to make this plausible and not try to put the burden entirely on the maintainers here.

---

### Background

Today, ALE supports running `mypy` against a given file. This is super helpful to get static analysis in the editor. `mypy`, unfortunately, is dreadfully slow and running it against a single file often causes it to sprawl across imports, etc. This is helpful, but leads to a very poor user experience (in my opinion as a user). `mypy` has recently(?) introduced [`dmypy`](https://mypy.readthedocs.io/en/stable/mypy_daemon.html#basic-usage) which allows users to start a server that caches much of the information and run analysis much faster.

One _can_ detect `dmypy` as being up and running (by default) when the directory it was started from has `.dmypy.json` present whose contents look like

```json
{"pid": 155810, "connection_name": "/tmp/tmp9vo1oy2m/dmypy.sock"}
```

### Request

I'd love to be able to - when possible (this is the hard part I think) - use dmypy with ALE but that would require re-configuring ALE each time _I_ know that I am already running the dmypy server for that project.

#### First step towards better experience

I'm wondering if as a first step towards better behaviour we could detect the presence of that file in whatever directory `vim` is started in and auto-swap to `dmypy run` or `dmypy check` with the given file.

I think this shouldn't be too bad but I don't know if ALE already has a pattern like this for another language and if it's worth adding this kind of behaviour to the plugin.

#### Bigger step towards a better experience

**Long term** it would be _awesome_ for ALE to detect `dmypy` exists as an executable, and start it from whatever directory here or maybe in the parent(s) has mypy config.

This is super hard if only because `mypy` allows a range of files to hold configuration in and we'd have to be reasonably confident we've found a directory with that to start `dmypy` from. Then, how do we know what files to include in the start command? It becomes kind of nightmare-ish when you think about the variety of project layouts and possibilities and then "what's the smart/fast thing" versus "what's the better UX thing".

Honestly, I'm not a vim plugin developer and haven't done much, nor have I dug into ALE's internals so this isn't something I have my hopes high for.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.