simplebench.reporters.validators.validators module🔗
Validators for reporters stuff.
- simplebench.reporters.validators.validators.resolve_type_hints(
- callback: Callable,
Resolve the type hints for a callback function.
- Parameters:
callback – The callback function to resolve type hints for.
- Returns:
A dictionary mapping parameter names to their resolved types.
- Raises:
SimpleBenchTypeError – If the type hints cannot be resolved.
- simplebench.reporters.validators.validators.validate_call_parameter( ) None[source]🔗
Validate a parameter of the callback function.
The parameter must exist, be of the expected type, and be a keyword-only parameter.
- Parameters:
call – The callback function to validate.
expected_type – The expected type of the parameter.
param_name – The name of the parameter to validate.
- Raises:
SimpleBenchTypeError – If the parameter is invalid.
- simplebench.reporters.validators.validators.validate_report_renderer(
- renderer: ReportRenderer,
Validate the report renderer method.
Verifies the renderer method has the correct signature. This is functionally equivalent to the
ReportRendererprotocol.A renderer function must accept the following three keyword-only parameters:
case: Casesection: Sectionoptions: ReporterOptions
- Parameters:
renderer – The renderer function to validate.
- Returns:
The validated renderer function.
- Raises:
SimpleBenchTypeError – If the renderer is invalid.
- simplebench.reporters.validators.validators.validate_reporter_callback(
- callback: Any,
- simplebench.reporters.validators.validators.validate_reporter_callback( ) ReporterCallback | None
Validate the reporter callback function.
Verifies the callback function has the correct signature.
If called without an
allow_noneparameter, the returned value will be guaranteed to conform to theReporterCallbackprotocol and type checkers will automatically type-narrow it.If called with an
allow_none=Trueparameter, the validator will accept either aReporterCallbackconformant method orNoneas valid.If an explicit
allow_noneparameter is passed, regardless of whetherallow_none=Trueorallow_none=False, the return type determined by static type checkers will beReporterCallback | None.A callback function must accept the following four keyword-only parameters:
case: Casesection: Sectionoutput_format: Formatoutput: Any
- Parameters:
callback – The callback function to validate.
allow_none – Whether to allow
Noneas a valid value for the callback. Defaults toFalse.
- Returns:
The validated callback function or
None.- Raises:
SimpleBenchTypeError – If the callback is invalid.