pyvista.core._validation.check.check_iterable_items#

check_iterable_items(
iterable_obj,
/,
item_type,
*,
allow_subclass=True,
name='Iterable',
)[source]#

Check if an iterable’s items all have a specified type.

Parameters:
iterable_objIterable

Iterable to check.

item_typetype | tuple[type, …]

Class type(s) to check for. Each element of the sequence must have the type or one of the types specified.

allow_subclassbool, default: True

If True, the type of the iterable items must be any of the given types or a subclass thereof. Otherwise, subclasses are not allowed.

namestr, default: “Iterable”

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

Raises:
TypeError

If any of the items in the iterable have an incorrect type.

Examples

Check if a tuple only has int or float elements.

>>> from pyvista import _validation
>>> _validation.check_iterable_items((1, 2, 3.0), (int, float))

Check if a list only has list elements.

>>> from pyvista import _validation
>>> _validation.check_iterable_items([[1], [2], [3]], list)