Skip to content

Commit

Permalink
fix: error context type
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuyoshicho committed Jul 27, 2024
1 parent 5f3319f commit 0f382bd
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions mypy_to_rdjson/mypy_to_rdjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import json
import sys

from typing import Any, Dict, TextIO


Expand All @@ -35,23 +34,29 @@ def mypy_to_rdjson(jsonlines: TextIO):
# If there is a rule name, append it to the message
error_code = d.get("code", None)
if error_code is not None:
message = f"{message} ({error_code})"

rdjson["diagnostics"].append(
{
"message": message,
"severity": d["severity"].upper(),
"location": {
"path": d["file"],
"range": {
"start": {
"line": d["line"],
"column": d["column"],
},
message = f"{message} [{error_code}]"

# mypy errror context: ignore it. not support display (line&column are undefined)
# severity: note
# line and column: -1,-1
if (d["severity"].upper() == "NOTE"
and int(d["line"]) == -1
and int(d["column"]) == -1):
continue

rdjson["diagnostics"].append({
"message": message,
"severity": d["severity"].upper(),
"location": {
"path": d["file"],
"range": {
"start": {
"line": d["line"],
"column": d["column"],
},
},
}
)
},
})

return json.dumps(rdjson)

Expand Down

0 comments on commit 0f382bd

Please sign in to comment.