Skip to content

Commit 2274633

Browse files
committed
Don't offer a code action for a diagnostic with no diagnostic "code"
Per the lsp spec, a diagnostic code, if one exists, should be a number or a string. At least one error message (the help message for missing imports) doesn't include a code, so the parse_line function sets it to "None". When this happens, don't offer a code action for that diagnostic
1 parent 6a9ca1d commit 2274633

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pylsp_mypy/plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,8 @@ def pylsp_code_actions(
604604
for diagnostic in context.get("diagnostics", []):
605605
if diagnostic["source"] != "mypy":
606606
continue
607+
if diagnostic.get("code") is None:
608+
continue
607609
code = diagnostic["code"]
608610
lineNumberEnd = diagnostic["range"]["end"]["line"]
609611
line = document.lines[lineNumberEnd]

0 commit comments

Comments
 (0)