Skip to content

loqs.backends.reps.base

Classes

Functions

is_rep_compatible

is_rep_compatible(output_cls: type[OperationRep], accepted: Sequence[type[OperationRep]]) -> bool

Check whether output_cls is compatible with any class in accepted.

Compatibility is issubclass-based rather than exact-equality-based: output_cls is compatible if it is a subclass of (or the same class as) any entry in accepted. Since issubclass(X, X) is always True, this is a strict generalization of comparing two concrete classes for equality -- a caller that (as is typical) declares only exact concrete classes in accepted sees identical behavior to an equality check, but a caller may also declare a coarse-grained capability like accepted=[InstrumentRep] to mean "accepts any instrument representation."

Parameters:

Name Type Description Default
output_cls type[OperationRep]

The candidate class to check.

required
accepted Sequence[type[OperationRep]]

The classes to check output_cls against.

required

Returns:

Type Description
bool

True if output_cls is a subclass of any class in accepted.