Skip to main content

lenient_issubclass

Checks if an object is a class and a subclass of a given type or tuple of types, avoiding errors if the first argument is not a class.

def lenient_issubclass(
cls: Any,
class_or_tuple: AnyType | tuple[AnyType, ...]
) - > bool

Checks if a class is a subclass of another class or tuple of classes without raising a TypeError if the first argument is not a type.

Parameters

NameTypeDescription
clsAnyThe object to check for subclass status.
class_or_tuple`AnyTypetuple[AnyType, ...]`

Returns

TypeDescription
boolTrue if the first argument is a class and is a subclass of the second argument, otherwise False.