Skip to content

Filter out astroid errors from the bot comment #6773

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 17 additions & 24 deletions tests/primer/primer_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,44 +184,37 @@ def _create_comment(

# Create comment for new messages
count = 1
fatal_count = 1
new_non_fatal_messages = ""
new_fatal_messages = ""
astroid_errors = 0
new_non_astroid_messages = ""
if new_messages:
print("Now emitted:")
for message in new_messages:
if message["type"] == "fatal":
filepath = str(message["path"]).replace(
str(package_data.clone_directory), ""
)
new_fatal_messages += (
f"{fatal_count}) {message['symbol']}:\n*{message['message']}*\n"
"**Please check your changes on the following file**:\n"
f"{package_data.url}/blob/{package_data.branch}{filepath}#L{message['line']}\n"
)
print(message)
fatal_count += 1
filepath = str(message["path"]).replace(
str(package_data.clone_directory), ""
)
# Existing astroid errors may still show up as "new" because the timestamp
# in the message is slightly different.
if message["symbol"] == "astroid-error":
astroid_errors += 1
else:
filepath = str(message["path"]).replace(
str(package_data.clone_directory), ""
)
new_non_fatal_messages += (
new_non_astroid_messages += (
f"{count}) {message['symbol']}:\n*{message['message']}*\n"
f"{package_data.url}/blob/{package_data.branch}{filepath}#L{message['line']}\n"
)
print(message)
count += 1

if new_fatal_messages:
if astroid_errors:
comment += (
"The following **fatal messages** are now emitted: 💣💥\n\n<details>\n\n"
+ new_fatal_messages
+ "\n</details>\n\n"
f"{astroid_errors} error(s) were found stemming from the `astroid` library. "
"This is unlikely to have been caused by your changes. "
"A GitHub Actions warning links directly to the crash report template. "
"Please open an issue against `astroid` if one does not exist already. \n\n"
)
if new_non_fatal_messages:
if new_non_astroid_messages:
comment += (
"The following messages are now emitted:\n\n<details>\n\n"
+ new_non_fatal_messages
+ new_non_astroid_messages
+ "\n</details>\n\n"
)

Expand Down