simplebench.reporters.validators package🔗

simplebench.reporters.validators package.

Exports:
  • validate_reporter_callback

  • validate_report_renderer

  • ReportersValidatorsErrorTag

simplebench.reporters.validators.validate_report_renderer(
renderer: ReportRenderer,
) ReportRenderer[source]🔗

Validate the report renderer method.

Verifies the renderer method has the correct signature. This is functionally equivalent to the ReportRenderer protocol.

A renderer function must accept the following three keyword-only parameters:

  • case: Case

  • section: Section

  • options: ReporterOptions

Parameters:

renderer – The renderer function to validate.

Returns:

The validated renderer function.

Raises:

SimpleBenchTypeError – If the renderer is invalid.

simplebench.reporters.validators.validate_reporter_callback(
callback: Any,
*,
allow_none: bool = False,
) ReporterCallback | None[source]🔗

Validate the reporter callback function.

Verifies the callback function has the correct signature.

If called without an allow_none parameter, the returned value will be guaranteed to conform to the ReporterCallback protocol and type checkers will automatically type-narrow it.

If called with an allow_none=True parameter, the validator will accept either a ReporterCallback conformant method or None as valid.

If an explicit allow_none parameter is passed, regardless of whether allow_none=True or allow_none=False, the return type determined by static type checkers will be ReporterCallback | None.

A callback function must accept the following four keyword-only parameters:

  • case: Case

  • section: Section

  • output_format: Format

  • output: Any

Parameters:
  • callback – The callback function to validate.

  • allow_none – Whether to allow None as a valid value for the callback. Defaults to False.

Returns:

The validated callback function or None.

Raises:

SimpleBenchTypeError – If the callback is invalid.

Submodules🔗