Skip to content

Commit

Permalink
fix: non error json
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuyoshicho committed Jul 27, 2024
1 parent b3a2520 commit a5842b0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mypy_to_rdjson/mypy_to_rdjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@

import json
import sys
from typing import Any, Dict, TextIO
from typing import (Any, Dict, List, TextIO)


def mypy_to_rdjson(jsonlines: TextIO):
mypy_result: List = []
for json_item in jsonlines.readlines():
mypy_result.append(json.loads(json_item))

# "$schema": "https://raw.githubusercontent.com/reviewdog/reviewdog/master/proto/rdf/jsonschema/DiagnosticResult.json",
rdjson: Dict[str, Any] = {
"source": {
Expand All @@ -27,6 +23,14 @@ def mypy_to_rdjson(jsonlines: TextIO):
"diagnostics": [],
}

mypy_result: List = []
try:
for json_item in jsonlines.readlines():
mypy_result.append(json.loads(json_item))
except Exception:
# decode error, return data nothing JSON
return json.dumps(rdjson)

d: Dict
for d in mypy_result:
message = d["message"]
Expand Down

0 comments on commit a5842b0

Please sign in to comment.