Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove add_metaclass #5577

Merged
merged 2 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions holoviews/core/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import param

from param.parameterized import add_metaclass

from . import util
from .pprint import PrettyPrinter

Expand Down Expand Up @@ -85,8 +83,7 @@ def pipelined_call(*args, **kwargs):
return pipelined_call


@add_metaclass(AccessorPipelineMeta)
class Apply:
class Apply(metaclass=AccessorPipelineMeta):
"""
Utility to apply a function or operation to all viewable elements
inside the object.
Expand Down Expand Up @@ -288,8 +285,7 @@ def transform(self, *args, **kwargs):
return self.__call__('transform', **kwargs)


@add_metaclass(AccessorPipelineMeta)
class Redim:
class Redim(metaclass=AccessorPipelineMeta):
"""
Utility that supports re-dimensioning any HoloViews object via the
redim method.
Expand Down Expand Up @@ -488,8 +484,7 @@ def values(self, specs=None, **ranges):
return self._redim('values', specs, **ranges)


@add_metaclass(AccessorPipelineMeta)
class Opts:
class Opts(metaclass=AccessorPipelineMeta):

def __init__(self, obj, mode=None):
self._mode = mode
Expand Down
19 changes: 9 additions & 10 deletions holoviews/core/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import param
import pandas as pd # noqa

from param.parameterized import add_metaclass, ParameterizedMetaclass
from param.parameterized import ParameterizedMetaclass

from ..accessors import Redim
from ..dimension import (
Expand Down Expand Up @@ -236,8 +236,7 @@ def pipelined_fn(*args, **kwargs):
return pipelined_fn


@add_metaclass(PipelineMeta)
class Dataset(Element):
class Dataset(Element, metaclass=PipelineMeta):
"""
Dataset provides a general baseclass for Element types that
contain structured data and supports a range of data formats.
Expand Down Expand Up @@ -290,7 +289,7 @@ class to each underlying element.
cls.param.warning(cls, msg.format(class_name=class_name, apply_args=apply_args))
return data.apply(cls, per_element=True, kdims=kdims, vdims=vdims, **kwargs)
else:
return super(Dataset, cls).__new__(cls)
return super().__new__(cls)

def __init__(self, data, kdims=None, vdims=None, **kwargs):
from ...operation.element import (
Expand Down Expand Up @@ -332,7 +331,7 @@ def __init__(self, data, kdims=None, vdims=None, **kwargs):
initialized = Interface.initialize(type(self), data, kdims, vdims,
datatype=kwargs.get('datatype'))
(data, self.interface, dims, extra_kws) = initialized
super(Dataset, self).__init__(data, **dict(kwargs, **dict(dims, **extra_kws)))
super().__init__(data, **dict(kwargs, **dict(dims, **extra_kws)))
self.interface.validate(self, validate_vdims)

# Handle _pipeline property
Expand Down Expand Up @@ -369,7 +368,7 @@ def __init__(self, data, kdims=None, vdims=None, **kwargs):

def __getstate__(self):
"Ensures pipelines are dropped"
obj_dict = super(Dataset, self).__getstate__()
obj_dict = super().__getstate__()
if '_pipeline' in obj_dict:
pipeline = obj_dict['_pipeline']
obj_dict['_pipeline'] = pipeline.instance(operations=pipeline.operations[:1])
Expand Down Expand Up @@ -1195,21 +1194,21 @@ def clone(self, data=None, shared_data=True, new_type=None, link=True,
elif self._in_method and 'dataset' not in overrides:
overrides['dataset'] = self.dataset

return super(Dataset, self).clone(data, shared_data, new_type, *args, **overrides)
return super().clone(data, shared_data, new_type, *args, **overrides)

# Overrides of superclass methods that are needed so that PipelineMeta
# will find them to wrap with pipeline support
@wraps(Dimensioned.options)
def options(self, *args, **kwargs):
return super(Dataset, self).options(*args, **kwargs)
return super().options(*args, **kwargs)

@wraps(LabelledData.map)
def map(self, *args, **kwargs):
return super(Dataset, self).map(*args, **kwargs)
return super().map(*args, **kwargs)

@wraps(LabelledData.relabel)
def relabel(self, *args, **kwargs):
return super(Dataset, self).relabel(*args, **kwargs)
return super().relabel(*args, **kwargs)

@property
def iloc(self):
Expand Down
5 changes: 1 addition & 4 deletions holoviews/plotting/plotly/callbacks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from weakref import WeakValueDictionary

from param.parameterized import add_metaclass

from ...streams import (
Stream, Selection1D, RangeXY, RangeX, RangeY, BoundsXY, BoundsX, BoundsY,
SelectionXY
Expand Down Expand Up @@ -38,8 +36,7 @@ def __call__(cls, *args, **kwargs):
return inst


@add_metaclass(PlotlyCallbackMetaClass)
class PlotlyCallback:
class PlotlyCallback(metaclass=PlotlyCallbackMetaClass):

def __init__(self, plot, streams, source, **params):
self.plot = plot
Expand Down