simplebench.type_proxies.case_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.case_type_proxy.CaseTypeProxy[source]🔗

Bases: LazyTypeProxy[Case]

A special proxy class that acts like the Case 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 Case type.

Warning

Do not attempt to import Case 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 Case class instead if an actual Case instance is needed.

simplebench.type_proxies.case_type_proxy.is_case(obj: object) TypeGuard[Case][source]🔗

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

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

Usage:

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

obj (object) – The object to check.

Returns:

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

Return type:

TypeGuard[Case]