1313
1414from pylint .lint import Run
1515from pylint .message import Message
16- from pylint .reporters .json_reporter import JSONReporter , OldJsonExport
16+ from pylint .reporters .json_reporter import JSON2Reporter , JSONMessage
1717from pylint .testutils ._primer .package_to_lint import PackageToLint
1818from pylint .testutils ._primer .primer_command import (
1919 PackageData ,
@@ -57,12 +57,12 @@ def run(self) -> None:
5757
5858 @staticmethod
5959 def _filter_fatal_errors (
60- messages : list [OldJsonExport ],
60+ messages : list [JSONMessage ],
6161 ) -> list [Message ]:
6262 """Separate fatal errors so we can report them independently."""
6363 fatal_msgs : list [Message ] = []
6464 for raw_message in messages :
65- message = JSONReporter .deserialize (raw_message )
65+ message = JSON2Reporter .deserialize (raw_message )
6666 if message .category == "fatal" :
6767 if GITHUB_CRASH_TEMPLATE_LOCATION in message .msg :
6868 # Remove the crash template location if we're running on GitHub.
@@ -73,11 +73,11 @@ def _filter_fatal_errors(
7373
7474 @staticmethod
7575 def _print_msgs (msgs : list [Message ]) -> str :
76- return "\n " .join (f"- { JSONReporter .serialize (m )} " for m in msgs )
76+ return "\n " .join (f"- { JSON2Reporter .serialize (m )} " for m in msgs )
7777
7878 def _lint_package (
7979 self , package_name : str , data : PackageToLint
80- ) -> tuple [list [OldJsonExport ], list [Message ]]:
80+ ) -> tuple [list [JSONMessage ], list [Message ]]:
8181 # We want to test all the code we can
8282 enables = ["--enable-all-extensions" , "--enable=all" ]
8383 # Duplicate code takes too long and is relatively safe
@@ -86,15 +86,15 @@ def _lint_package(
8686 additional = ["--clear-cache-post-run=y" ]
8787 arguments = data .pylint_args + enables + disables + additional
8888 output = StringIO ()
89- reporter = JSONReporter (output )
89+ reporter = JSON2Reporter (output )
9090 print (f"Running 'pylint { ', ' .join (arguments )} '" )
9191 pylint_exit_code = - 1
9292 try :
9393 Run (arguments , reporter = reporter )
9494 except SystemExit as e :
9595 pylint_exit_code = int (e .code ) # type: ignore[arg-type]
9696 readable_messages : str = output .getvalue ()
97- messages : list [OldJsonExport ] = json .loads (readable_messages )
97+ messages : list [JSONMessage ] = json .loads (readable_messages )[ "messages" ]
9898 fatal_msgs : list [Message ] = []
9999 if pylint_exit_code % 2 == 0 :
100100 print (f"Successfully primed { package_name } ." )
0 commit comments