pyvista.core._validation.check.check_type#

check_type(obj, /, classinfo, *, name='Object')[source]#

Check if an object is one of the given type or types.

Parameters:
objAny

Object to check.

classinfotype | tuple[type, …]

type or tuple of types. Object must be one of the types.

namestr, default: “Object”

Variable name to use in the error messages if any are raised.

Raises:
TypeError

If object is not any of the given types.

See also

check_instance

Notes

The use of check_instance() is generally preferred as it allows subclasses. Use check_type() only for cases where exact types are necessary.

Examples

Check if an object is type dict or set.

>>> from pyvista import _validation
>>> _validation.check_type({'spam': "eggs"}, (dict, set))