Browse Source

include file_path in CheckJsonParses PRESUBMIT check

This is to test new feature added in
https://issues.chromium.org/404837554

Bug: 404837554
Change-Id: I3da40202091e08d9104f2b69d2a372ed786b3d36
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6478701
Auto-Submit: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Yiwei Zhang 4 months ago
parent
commit
e5cd6f84f0
1 changed files with 6 additions and 2 deletions
  1. 6 2
      presubmit_canned_checks.py

+ 6 - 2
presubmit_canned_checks.py

@@ -2654,12 +2654,16 @@ def CheckJsonParses(input_api, output_api, file_filter=None):
         with _io.open(f.AbsoluteLocalPath(), encoding='utf-8') as j:
             try:
                 json.load(j)
-            except ValueError:
+            except json.JSONDecodeError:
                 # Just a warning for now, in case people are using JSON5
                 # somewhere.
                 warnings.append(
                     output_api.PresubmitPromptWarning(
-                        '%s does not appear to be valid JSON.' % f.LocalPath()))
+                        f"{f.LocalPath()} doesn't appear to be valid JSON.",
+                        locations=[
+                            output_api.PresubmitResultLocation(
+                                file_path=f.LocalPath()),
+                        ]))
     return warnings