Dbg

This module provides functionality for collecting data about environment for including it to bug reports. It’s inspired by Scooby (check it out if functionality of this module is not enough).

Set App.bug_report to enable this functionality.

yuio.dbg.print_report(
*,
dest: TextIO | None = None,
settings: ReportSettings | bool | None = None,
app: App[Any] | None = None,
)

Collect and print debug report to the given dest.

Parameters:
  • dest – destination stream for printing bug report, default is stdout.

  • settings – settings for bug report generation.

  • app

    main app of the project, used to extract project’s version and dependencies.

    Note

    If your app defined in the __main__ module, Yuio will not be able to extract its dependencies and print their versions.

    We recommend defining app in a separate file and importing it to the __main__ module.

class yuio.dbg.ReportSettings(
package: str | ModuleType | None = None,
dependencies: list[str | ModuleType] | None = None,
collectors: list[EnvCollector | Report] | None = None,
)

Settings for collecting debug data.

package: str | types.ModuleType | None

Root package. Used to collect dependencies.

dependencies: list[str | types.ModuleType] | None

List of additional dependencies to include to version report.

collectors: list[EnvCollector | Report] | None

List of additional env collectors to run.

class yuio.dbg.Report(title: str, items: list[str | tuple[str, str]]=<factory>)

An environment report.

title: str

Report title.

items: list[str | tuple[str, str]]

Report items. Each item can be a string or a key-value pair of strings.

type yuio.dbg.EnvCollector = Callable[[], Report]

Type alias for report collector.