A Rich traceback renderer with the given options. Pass an instance as `ConsoleRenderer`'s ``exception_formatter`` argument. See :class:`rich.traceback.Traceback` for details on the arguments. If *width* is `None`, the terminal width is used. If the width can't be determined,
| 391 | |
| 392 | @dataclass |
| 393 | class RichTracebackFormatter: |
| 394 | """ |
| 395 | A Rich traceback renderer with the given options. |
| 396 | |
| 397 | Pass an instance as `ConsoleRenderer`'s ``exception_formatter`` argument. |
| 398 | |
| 399 | See :class:`rich.traceback.Traceback` for details on the arguments. |
| 400 | |
| 401 | If *width* is `None`, the terminal width is used. If the width can't be |
| 402 | determined, fall back to 80. |
| 403 | |
| 404 | .. versionadded:: 23.2.0 |
| 405 | |
| 406 | .. versionchanged:: 25.4.0 |
| 407 | Default *width* is ``None`` to have full width and reflow support. |
| 408 | Passing ``-1`` as width is deprecated, use ``None`` instead. |
| 409 | *word_wrap* is now True by default. |
| 410 | |
| 411 | .. versionadded:: 25.4.0 *code_width* |
| 412 | |
| 413 | .. versionchanged:: 26.1.0 |
| 414 | ``None`` is now valid for *color_system* and disables color output. |
| 415 | """ |
| 416 | |
| 417 | color_system: ( |
| 418 | Literal["auto", "standard", "256", "truecolor", "windows"] | None |
| 419 | ) = "truecolor" |
| 420 | show_locals: bool = True |
| 421 | max_frames: int = 100 |
| 422 | theme: str | None = None |
| 423 | word_wrap: bool = True |
| 424 | extra_lines: int = 3 |
| 425 | width: int | None = None |
| 426 | code_width: int | None = 88 |
| 427 | indent_guides: bool = True |
| 428 | locals_max_length: int = 10 |
| 429 | locals_max_string: int = 80 |
| 430 | locals_hide_dunder: bool = True |
| 431 | locals_hide_sunder: bool = False |
| 432 | suppress: Sequence[str | ModuleType] = () |
| 433 | |
| 434 | def __call__(self, sio: TextIO, exc_info: ExcInfo) -> None: |
| 435 | if self.width == -1: |
| 436 | warnings.warn( |
| 437 | "Use None to use the terminal width instead of -1.", |
| 438 | DeprecationWarning, |
| 439 | stacklevel=2, |
| 440 | ) |
| 441 | self.width = None |
| 442 | |
| 443 | sio.write("\n") |
| 444 | |
| 445 | console = Console( |
| 446 | file=sio, color_system=self.color_system, width=self.width |
| 447 | ) |
| 448 | tb = Traceback.from_exception( |
| 449 | *exc_info, |
| 450 | show_locals=self.show_locals, |
no outgoing calls
no test coverage detected
searching dependent graphs…