DataSetAccessor

DataSetAccessor#

class DataSetAccessor(dataset: Any)[source]#

Structural protocol for third-party accessor classes.

An accessor class must accept the dataset instance as its single __init__ argument. Any public methods on the class become available as dataset.<namespace>.<method>(...) once the class is registered with register_dataset_accessor().

This Protocol exists primarily for static type analysis: plugin authors can annotate accessor_cls: type[DataSetAccessor] (or use it as a return annotation) to have mypy/pyright check that their accessor class conforms. The runtime isinstance check is intentionally permissive (every class has __init__), so prefer the static-typing use.

Added in version 0.48.0.

Examples

Declare an accessor that satisfies the protocol.

>>> from pyvista import DataSetAccessor
>>> class MyAccessor:
...     def __init__(self, dataset):
...         self._dataset = dataset
>>> isinstance(MyAccessor(None), DataSetAccessor)
True

Methods#