Skip to content

Commit 03975b7

Browse files
committed
Expose generic mypy error as diagnostic
1 parent 5c1bd61 commit 03975b7

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,22 @@ 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+
{
286+
"source": "mypy",
287+
"range": {
288+
"start": {"line": 0, "character": 0},
289+
# Client is supposed to clip end column to line length.
290+
"end": {"line": 0, "character": 1000},
291+
},
292+
"message": errors,
293+
"severity": 1, # Error
294+
}
295+
)
296+
281297
for line in report.splitlines():
282298
log.debug("parsing: line = %r", line)
283299
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)