agronholm / agronholm/exceptiongroup
Add note helper?
- Ngôn ngữ chính
- Python
- Star
- 49
- Fork
- 23
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
Just curious, I find myself using:
```python
if sys.version_info < (3, 11):
err.__notes__ = getattr(err, "__notes__", []) + [msg] # type: ignore[attr-defined]
else:
err.add_note(msg) # pylint: disable=no-member
```
in order to add notes to the exceptions contained in the exception group. (See cattrs, where I got the idea from). There's already a helper function (`exceptiongroup.catch()`), would an `add_note()` helper be helpful and in scope?
This would be the definition, I think:
```python
def add_note(err: BaseException, msg: str) -> None:
if sys.version_info < (3, 11):
err.__notes__ = getattr(err, "__notes__", []) + [msg]
else:
err.add_note(msg)
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.