Skip to content

Commit 155298f

Browse files
[crash template] Link to blank issue so it's possible to copy paste
1 parent 5e94497 commit 155298f

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

pylint/lint/utils.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
from __future__ import annotations
66

77
import contextlib
8+
import platform
89
import sys
910
import traceback
1011
from collections.abc import Iterator, Sequence
1112
from datetime import datetime
1213
from pathlib import Path
1314

14-
from pylint.constants import PYLINT_HOME
15+
from pylint.constants import PYLINT_HOME, full_version
1516

1617

1718
def prepare_crash_report(ex: Exception, filepath: str, crash_file_path: str) -> Path:
@@ -26,8 +27,9 @@ def prepare_crash_report(ex: Exception, filepath: str, crash_file_path: str) ->
2627
First, please verify that the bug is not already filled:
2728
https://github.com/PyCQA/pylint/issues/
2829
29-
Then create a new crash issue:
30-
https://github.com/PyCQA/pylint/issues/new?assignees=&labels=crash%2Cneeds+triage&template=BUG-REPORT.yml
30+
Then create a new issue:
31+
https://github.com/PyCQA/pylint/issues/new?labels=Crash 💥%2CNeeds triage 📥
32+
3133
3234
"""
3335
template += f"""
@@ -63,10 +65,32 @@ def prepare_crash_report(ex: Exception, filepath: str, crash_file_path: str) ->
6365
```python
6466
"""
6567
template += traceback.format_exc()
66-
template += """
68+
template += f"""
6769
```
6870
71+
6972
</details>
73+
74+
### Expected behavior
75+
76+
No crash.
77+
78+
### Pylint version
79+
80+
```shell
81+
{full_version}
82+
```
83+
84+
### OS / Environment
85+
86+
{sys.platform} ({platform.system()})
87+
88+
### Additional dependencies
89+
90+
<!--
91+
Please remove this part if you're not using any of
92+
your dependencies in the example.
93+
-->
7094
"""
7195
try:
7296
with open(issue_template_path, "a", encoding="utf8") as f:

tests/lint/test_utils.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import pytest
99

10+
from pylint.constants import full_version
1011
from pylint.lint.utils import get_fatal_error_message, prepare_crash_report
1112
from pylint.testutils._run import _Run as Run
1213

@@ -17,19 +18,22 @@ def test_prepare_crash_report(tmp_path: PosixPath) -> None:
1718
python_content = "from shadok import MagicFaucet"
1819
with open(python_file, "w", encoding="utf8") as f:
1920
f.write(python_content)
21+
template_path = None
2022
try:
21-
raise Exception(exception_content) # pylint: disable=broad-exception-raised
22-
except Exception as ex: # pylint: disable=broad-except
23+
raise ValueError(exception_content)
24+
except ValueError as ex:
2325
template_path = prepare_crash_report(
2426
ex, str(python_file), str(tmp_path / "pylint-crash-%Y.txt")
2527
)
26-
assert str(tmp_path) in str(template_path) # pylint: disable=used-before-assignment
28+
assert str(tmp_path) in str(template_path)
2729
with open(template_path, encoding="utf8") as f:
2830
template_content = f.read()
2931
assert python_content in template_content
3032
assert exception_content in template_content
3133
assert "in test_prepare_crash_report" in template_content
32-
assert "raise Exception(exception_content)" in template_content
34+
assert "raise ValueError(exception_content)" in template_content
35+
assert "<details open>" in template_content
36+
assert full_version in template_content
3337

3438

3539
def test_get_fatal_error_message() -> None:

0 commit comments

Comments
 (0)