Skip to content

Commit 611e67f

Browse files
committed
Expose generic mypy error as diagnostic
1 parent 5c1bd61 commit 611e67f

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

.github/workflows/python-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ jobs:
3838
run: |
3939
# stop the build if there are Python syntax errors or undefined names
4040
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
41-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
42-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
41+
# exit-zero treats all errors as warnings
42+
flake8 . --count --exit-zero --statistics
4343
- name: Check black formatting
4444
run: |
4545
# stop the build if black detect any changes

pylsp_mypy/plugin.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,20 @@ def pylsp_lint(
278278
log.debug("errors:\n%s", errors)
279279

280280
diagnostics = []
281+
282+
# Expose generic mypy error on the first line.
283+
if errors:
284+
diagnostics.append({
285+
"source": "mypy",
286+
"range": {
287+
"start": {"line": 0, "character": 0},
288+
# Client is supposed to clip end column to line length.
289+
"end": {"line": 0, "character": 1000},
290+
},
291+
"message": errors,
292+
"severity": 1, # Error
293+
})
294+
281295
for line in report.splitlines():
282296
log.debug("parsing: line = %r", line)
283297
diag = parse_line(line, document)

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ install_requires =
2323
mypy
2424
toml
2525

26+
[flake8]
27+
max-complexity = 10
28+
max-line-length = 127
2629

2730
[options.entry_points]
2831
pylsp = pylsp_mypy = pylsp_mypy.plugin

0 commit comments

Comments
 (0)