def add_note(err: BaseException, msg: str) -> None:
    """Adds a note to an exception inplace."""
    if sys.version_info < (3, 11):
        err.__notes__ = [*getattr(err, "__notes__", []), msg]  # type: ignore[attr-defined]
    else:
        err.add_note(msg)
Adds a note to an exception inplace.
testing/code/test_excinfo.py