Skip to content

Commit 731df04

Browse files
Filter out astroid errors from the bot comment (#6773)
1 parent 90b6d1a commit 731df04

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

tests/primer/primer_tool.py

+17-24
Original file line numberDiff line numberDiff line change
@@ -184,44 +184,37 @@ def _create_comment(
184184

185185
# Create comment for new messages
186186
count = 1
187-
fatal_count = 1
188-
new_non_fatal_messages = ""
189-
new_fatal_messages = ""
187+
astroid_errors = 0
188+
new_non_astroid_messages = ""
190189
if new_messages:
191190
print("Now emitted:")
192191
for message in new_messages:
193-
if message["type"] == "fatal":
194-
filepath = str(message["path"]).replace(
195-
str(package_data.clone_directory), ""
196-
)
197-
new_fatal_messages += (
198-
f"{fatal_count}) {message['symbol']}:\n*{message['message']}*\n"
199-
"**Please check your changes on the following file**:\n"
200-
f"{package_data.url}/blob/{package_data.branch}{filepath}#L{message['line']}\n"
201-
)
202-
print(message)
203-
fatal_count += 1
192+
filepath = str(message["path"]).replace(
193+
str(package_data.clone_directory), ""
194+
)
195+
# Existing astroid errors may still show up as "new" because the timestamp
196+
# in the message is slightly different.
197+
if message["symbol"] == "astroid-error":
198+
astroid_errors += 1
204199
else:
205-
filepath = str(message["path"]).replace(
206-
str(package_data.clone_directory), ""
207-
)
208-
new_non_fatal_messages += (
200+
new_non_astroid_messages += (
209201
f"{count}) {message['symbol']}:\n*{message['message']}*\n"
210202
f"{package_data.url}/blob/{package_data.branch}{filepath}#L{message['line']}\n"
211203
)
212204
print(message)
213205
count += 1
214206

215-
if new_fatal_messages:
207+
if astroid_errors:
216208
comment += (
217-
"The following **fatal messages** are now emitted: 💣💥\n\n<details>\n\n"
218-
+ new_fatal_messages
219-
+ "\n</details>\n\n"
209+
f"{astroid_errors} error(s) were found stemming from the `astroid` library. "
210+
"This is unlikely to have been caused by your changes. "
211+
"A GitHub Actions warning links directly to the crash report template. "
212+
"Please open an issue against `astroid` if one does not exist already. \n\n"
220213
)
221-
if new_non_fatal_messages:
214+
if new_non_astroid_messages:
222215
comment += (
223216
"The following messages are now emitted:\n\n<details>\n\n"
224-
+ new_non_fatal_messages
217+
+ new_non_astroid_messages
225218
+ "\n</details>\n\n"
226219
)
227220

0 commit comments

Comments
 (0)