✨ Add pretty_exceptions_suppress option to extend suppressed frames in pretty exceptions - #770
✨ Add pretty_exceptions_suppress option to extend suppressed frames in pretty exceptions#770tlambert03 wants to merge 3 commits into
pretty_exceptions_suppress option to extend suppressed frames in pretty exceptions#770Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
I'm not a maintainer, but the change looks pretty straight-forward to me. |
|
📝 Docs preview for commit 9385bb4 at: https://2ae49c39.typertiangolo.pages.dev Modified Pages |
|
I'll have a look! 🙏 |
pretty_exceptions_suppress option to extend suppressed frames in pretty exceptionspretty_exceptions_suppress option to extend suppressed frames in pretty exceptions
svlandeg
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
While I can see how it might occassionally be useful to set this explicitely, I'm not sure how frequent this type of use-case is. And we always have to balance new features vs. the maintenance cost. Either way - I'll let Tiangolo decide on whether or not he'll want to include the feature in the library.
I left some further comments to try and get this PR into a good state to merge it, if Tiangolo agrees.
|
|
||
| </div> | ||
|
|
||
| ## Suppress Frames from Pretty Exceptions |
There was a problem hiding this comment.
There's a few things we need to do to improve the docs here:
- Move this section up to BEFORE the section "Disable Short Output"
- Anywhere on this page, whenever it talks about "Click and Typer" being excluded, it should instead reference the "suppressed libraries" (or such, depending on exact wording used in the new section)
- The example given here should be a full example, as in all other sections on this page. That means it should be a fully runnable code example that has
sqlmodellines in its error stack trace, and the output should be displayed so the user can verify it - The example should be tested properly in the test suite at
tests/test_tutorial/test_exceptions, at which point it should check e.g. thatsqlalchemyis part of the output (or not) with the setting off (or on).
BTW - is "frames" the correct term here? I would have opted for "Libraries", but I'm not sure either way.
|
|
||
| ## Disable Pretty Exceptions | ||
|
|
||
| You can also entirely disable pretty exceptions with the parameter `pretty_exceptions_enable=False`: |
There was a problem hiding this comment.
Question: what should happen when both pretty_exceptions_short=False and pretty_exceptions_suppress=[sqlalchemy] are set?
| ## Suppress Frames from Pretty Exceptions | ||
|
|
||
| By default, typer will **omit** all the parts of the traceback that come from the internal parts in Typer and Click, but you can exclude frames from additional | ||
| frameworks using `pretty_exceptions_suppress`, which should be a list of modules or str paths. |
There was a problem hiding this comment.
How exactly would "str paths" be defined?
|
This pull request has a merge conflict that needs to be resolved. |
|
As this PR has been waiting for the original user for a while but seems to be inactive, it's now going to be closed. But if there's anyone interested, feel free to create a new PR. |
This pull request extends the pretty_exceptions feature by adding
pretty_exceptions_suppress, which lets the user pass an iterable of modules or string paths to suppress in addition to Typer and click