11
11
from itertools import chain
12
12
13
13
from pylint .lint import Run
14
+ from pylint .message import Message
14
15
from pylint .reporters import JSONReporter
15
16
from pylint .testutils ._primer .package_to_lint import PackageToLint
16
17
from pylint .testutils ._primer .primer_command import PackageMessages , PrimerCommand
22
23
class RunCommand (PrimerCommand ):
23
24
def run (self ) -> None :
24
25
packages : PackageMessages = {}
25
-
26
26
for package , data in self .packages .items ():
27
- output = self ._lint_package (data )
28
- packages [package ] = output
27
+ packages [package ] = self ._lint_package (data )
29
28
print (f"Successfully primed { package } ." )
30
29
31
30
astroid_errors = []
32
31
other_fatal_msgs = []
33
32
for msg in chain .from_iterable (packages .values ()):
34
- if msg [ "type" ] == "fatal" :
33
+ if msg . category == "fatal" :
35
34
# Remove the crash template location if we're running on GitHub.
36
35
# We were falsely getting "new" errors when the timestamp changed.
37
- assert isinstance (msg [ "message" ] , str )
38
- if GITHUB_CRASH_TEMPLATE_LOCATION in msg [ "message" ] :
39
- msg [ "message" ] = msg [ "message" ] .rsplit (CRASH_TEMPLATE_INTRO )[0 ]
40
- if msg [ " symbol" ] == "astroid-error" :
36
+ assert isinstance (msg . msg , str )
37
+ if GITHUB_CRASH_TEMPLATE_LOCATION in msg . msg :
38
+ msg . msg = msg . msg .rsplit (CRASH_TEMPLATE_INTRO )[0 ]
39
+ if msg . symbol == "astroid-error" :
41
40
astroid_errors .append (msg )
42
41
else :
43
42
other_fatal_msgs .append (msg )
@@ -59,7 +58,7 @@ def run(self) -> None:
59
58
warnings .warn (f"Fatal errors traced to astroid: { astroid_errors } " )
60
59
assert not other_fatal_msgs , other_fatal_msgs
61
60
62
- def _lint_package (self , data : PackageToLint ) -> list [dict [ str , str | int ] ]:
61
+ def _lint_package (self , data : PackageToLint ) -> list [Message ]:
63
62
# We want to test all the code we can
64
63
enables = ["--enable-all-extensions" , "--enable=all" ]
65
64
# Duplicate code takes too long and is relatively safe
@@ -69,4 +68,4 @@ def _lint_package(self, data: PackageToLint) -> list[dict[str, str | int]]:
69
68
output = StringIO ()
70
69
reporter = JSONReporter (output )
71
70
Run (arguments , reporter = reporter , exit = False )
72
- return json .loads (output .getvalue ())
71
+ return [ Message ( * m ) for m in json .loads (output .getvalue ())]
0 commit comments