agronholm / agronholm/exceptiongroup

Add note helper?

Đang mở
#31 1 bình luận 3 reaction 0 người được giao Xem trên GitHub
enhancement
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á.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.