Skip to content

Hide frame from tracebacks #2207

Closed
@willmcgugan

Description

@willmcgugan
Member

Sometimes it is useful to completely omit a frame from a traceback. Suggest a local variable with a name like _rich_traceback_omit

Activity

olivierphi

olivierphi commented on Apr 26, 2022

@olivierphi

Not sure I understand correctly, sorry... 😅

Do you mean something like this?

@dataclass
class Frame:
    filename: str
    lineno: int
    name: str
    line: str = ""
    locals: Optional[Dict[str, pretty.Node]] = None
    _rich_traceback_omit: bool = False # <-- new opt-in allowing to exclude that frame

...which would be powered behind the scenes by something like the possibility to simply add _rich_traceback_omit = True to the locals of any Python object.
...and that we would detect when we create the Frame object, as we have frame_summary.f_locals at this point?

willmcgugan

willmcgugan commented on Apr 26, 2022

@willmcgugan
MemberAuthor

Essentially that. The idea is that Textual can remove things like descriptors from the traceback, so the user doesn't see noise from the library code.

We do something similar to omit library code (see suppress)

github-actions

github-actions commented on Apr 26, 2022

@github-actions

Did I solve your problem?

Why not buy the devs a coffee to say thanks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

acceptedTask was accepted

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @willmcgugan@olivierphi

    Issue actions

      Hide frame from tracebacks · Issue #2207 · Textualize/rich