simplebench.type_proxies package🔗
Special types used in simplebench.
The primary purpose of this module is to provide deferred imports for core types like Case to avoid circular import issues during module initialization while still allowing runtime type checks like isinstance() and issubclass() to work correctly.
- It can be used as follows:
from simplebench.types import CaseType # Lazy proxy for Case type
- It provides the following exports:
CaseType: A lazy-loading proxy for the Case type that can be used in isinstance() and issubclass() checks.
is_case(): A type-guard function to check if an object is a Case instance.
ReporterType: A lazy-loading proxy for the Reporter type that can be used in isinstance() and issubclass() checks.
is_reporter(): A type-guard function to check if an object is a Reporter instance.
ChoiceType: A lazy-loading proxy for the Choice type that can be used in isinstance() and issubclass() checks.
is_choice(): A type-guard function to check if an object is a Choice instance.
SessionType: A lazy-loading proxy for the Session type that can be used in isinstance() and issubclass() checks.
is_session(): A type-guard function to check if an object is a Session instance.
- class simplebench.type_proxies.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.
- class simplebench.type_proxies.ChoiceTypeProxy[source]🔗
Bases:
LazyTypeProxy[Choice]A special proxy class that acts like the Choice 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 Choice type.
Warning
Do not attempt to import Choice 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 Choice class instead if an actual Choice instance is needed.
- class simplebench.type_proxies.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.
- class simplebench.type_proxies.SessionTypeProxy[source]🔗
Bases:
LazyTypeProxy[Session]A special proxy class that acts like the Session type for runtime checks.
It can be used in isinstance and issubclass checks as if it were the actual Session type.
Warning
Do not attempt to import Session 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 Session class instead if an actual Session instance is needed.
- simplebench.type_proxies.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.
- simplebench.type_proxies.is_choice(obj: object) TypeGuard[Choice][source]🔗
A type-guard function that checks if an object is an instance of Choice.
This function uses the ChoiceTypeProxy to perform the check, allowing for deferred imports and avoiding circular dependencies. It has the same effect as isinstance(obj, Choice) but is safe to use without causing import issues. It also works seamlessly with static type checkers and IDEs.
Usage:
if is_choice(some_object): # Now `some_object` is treated as a `Choice` instance by static type checkers.
- simplebench.type_proxies.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.
- simplebench.type_proxies.is_session(obj: object) TypeGuard[Session][source]🔗
A type-guard function that checks if an object is an instance of Session.
This function uses the SessionTypeProxy to perform the check, allowing for deferred imports and avoiding circular dependencies. It has the same effect as isinstance(obj, Session) but is safe to use without causing import issues. It also works seamlessly with static type checkers and IDEs.
Usage:
if is_session(some_object): # Now `some_object` is treated as a `Session` instance by static type checkers.