-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[primer] Create a class for easier comparison of pylint results #6984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html | ||
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE | ||
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt | ||
|
||
from __future__ import annotations | ||
|
||
import json | ||
from collections.abc import Generator | ||
from pathlib import Path | ||
|
||
from pylint.testutils._primer.primer_command import Messages, PackageMessages | ||
|
||
|
||
class Comparator: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you rename this to If you're up for it perhaps we could even create an abstract class? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by astroid comparator ? Comparing a json dump of the generated ast ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it's the basic primer for pylint but for astroid ? It does not need a comparator right ? As if a crash exists it's always problem, and there's no crash on main. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, but I thinking of maybe running the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah sure I understood that :) It make sense to test astroid more in the astroid CI, because pylint's CI is already crowded so I think it's a really good idea too. |
||
def __init__(self, main_json: Path, pr_json: Path): | ||
main_messages = self._load_json(main_json) | ||
self.pr_messages = self._load_json(pr_json) | ||
self.missing_messages: PackageMessages = {} | ||
for package, messages in main_messages.items(): | ||
self.missing_messages[package] = [] | ||
for message in messages: | ||
try: | ||
self.pr_messages[package].remove(message) | ||
except ValueError: | ||
self.missing_messages[package].append(message) | ||
|
||
def __iter__( | ||
self, | ||
) -> Generator[tuple[str, Messages, Messages], None, None]: | ||
for package, missing_messages in self.missing_messages.items(): | ||
new_messages = self.pr_messages[package] | ||
if not missing_messages and not new_messages: | ||
print(f"PRIMER: No changes in {package}.") | ||
continue | ||
yield package, missing_messages, new_messages | ||
|
||
@staticmethod | ||
def _load_json(file_path: Path | str) -> PackageMessages: | ||
with open(file_path, encoding="utf-8") as f: | ||
result: PackageMessages = json.load(f) | ||
return result |
Uh oh!
There was an error while loading. Please reload this page.