simplebench.type_proxies.reporter_type_proxy module🔗

Provides a mechanism to create a lazy type proxy for the Case type for runtime checks.

The CaseTypeProxy class acts as a stand-in for the actual Case type, allowing for deferred imports and avoiding circular dependencies while still enabling runtime type checks and static type checking.

class simplebench.type_proxies.reporter_type_proxy.ReporterTypeProxy[source]🔗

Bases: LazyTypeProxy[Reporter]

A special proxy class that acts like the Reporter type for runtime checks.

It uses lazy loading to avoid circular import issues while still allowing runtime type checks and static type checking.

It can be used in isinstance and issubclass checks as if it were the actual Reporter type.

Warning

Do not attempt to import Reporter directly from this module, as it will lead to circular import issues and will not work as intended.

It is not intended to be instantiated directly; use the actual Reporter class instead if an actual Reporter instance is needed.

simplebench.type_proxies.reporter_type_proxy.is_reporter(obj: object) TypeGuard[Reporter][source]🔗

A type-guard function that checks if an object is an instance of Reporter.

This function uses the ReporterTypeProxy to perform the check, allowing for deferred imports and avoiding circular dependencies. It has the same effect as isinstance(obj, Reporter) but is safe to use without causing import issues. It also works seamlessly with static type checkers and IDEs.

Usage:

if is_reporter(some_object):
    # Now `some_object` is treated as a `Reporter` instance by static type checkers.
Parameters:

obj (object) – The object to check.

Returns:

True if the object is an instance of Reporter, False otherwise

Return type:

TypeGuard[Reporter]