PEP 678: Enriching Exceptions with Notes

I can’t speak for friendly-traceback, but it seems that with it would currently have trouble identifying where one note starts and another ends, so it wouldn’t be able to translate individual pieces (and leave unknown ones alone).
Or a GUI would have trouble hiding/collapsing individual notes.

Was a tuple of strings considered? The way to add a note could become something like:

@contextlib.contextmanager
def add_exc_note(note):
    try:
        yield
    except Exception as err:
        err.__notes__ += (note, )
        raise

That would have an additional benefit: writing a composable note-adding library (one that plays well with others) would be easier to do than one that removes other notes.

IMO, the expectation of what libraries should do when adding notes is pretty important to get right, even if the PEP says it’s not “a core part of the proposal”. Where else should it be specified? I don’t think interoperation with other libraries should be left to each individual library. Today’s libraries that want to set notes might be “top-level” – you probably won’t combine asyncio, trio and Hypothesis in unpredictable ways – but that’ll change if exception groups are successful.