Include notes when logging exceptions#684
Merged
hynek merged 16 commits intohynek:mainfrom Feb 3, 2025
Merged
Conversation
This adds support for the notes feature from https://peps.python.org/pep-0678/, which was introduced in Python 3.11.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
hynek
reviewed
Jan 4, 2025
src/structlog/tracebacks.py
Outdated
|
|
||
| exc_type: str | ||
| exc_value: str | ||
| exc_notes: str | None = None |
Owner
There was a problem hiding this comment.
hey sorry for the long delay – is there a reason why you chose to make it an optional str?
You mention it in the description but without reasoning and I think it would be more ergonomic to make it a tuple[str, ...]?
(tuple > list because it would keep Stack hashable)
Contributor
Author
There was a problem hiding this comment.
I forget; I think I was concerned about how it would show up in a particular system we have, but for no good reason. A tuple works better. Done! Sorry I lost track of this for a while.
Owner
There was a problem hiding this comment.
thanks! but ugh I'm so dumb, there already is a list in the class so it makes no sense to make this inconsistently a list. I'll fix it myself, this is on me.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This adds support for the notes feature from https://peps.python.org/pep-0678/, which was introduced in Python 3.11.
These notes are not included in
str, but they are included intraceback.print_exception, etc.; we should include them when logging, too.Note: an alternative option for formatting would be to include these in the
exc_valuestring.Pull Request Check List
mainbranch – use a separate branch!api.py.docs/api.rstby hand.versionadded,versionchanged, ordeprecateddirectives..rstand.mdfiles is written using semantic newlines.