Skip to content

Commit

Permalink
Pie lint (#5777)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Jul 4, 2023
1 parent bcdfae6 commit ee37d1e
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ repos:
- id: end-of-file-fixer
exclude: \.min\.js$
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.272
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.276
hooks:
- id: ruff
args: [holoviews]
Expand All @@ -27,7 +27,7 @@ repos:
hooks:
- id: clean-notebook
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
rev: v2.2.5
hooks:
- id: codespell
additional_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion holoviews/core/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def __getattr__(self, identifier):
pass

# Attributes starting with __ get name mangled
if identifier.startswith('_' + type(self).__name__) or identifier.startswith('__'):
if identifier.startswith(('_' + type(self).__name__, '__')):
raise AttributeError(f'Attribute {identifier} not found.')
elif self.fixed==True:
raise AttributeError(self._fixed_error % identifier)
Expand Down
2 changes: 1 addition & 1 deletion holoviews/element/tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Tiles(Element2D):
* Bounding box tile sources containing {XMIN}, {XMAX}, {YMIN}, {YMAX} variables
* Quadkey tile sources containin a {Q} variable
* Quadkey tile sources containing a {Q} variable
Tiles are defined in a pseudo-Mercator projection (EPSG:3857)
defined as eastings and northings. Any data overlaid on a tile
Expand Down
5 changes: 1 addition & 4 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ def _update_grid(self, plot):
return
replace = ['bounds', 'bands', 'visible', 'level', 'ticker', 'visible']
style_items = list(self.gridstyle.items())
both = {k: v for k, v in style_items if k.startswith('grid_') or k.startswith('minor_grid')}
both = {k: v for k, v in style_items if k.startswith(('grid_', 'minor_grid'))}
xgrid = {k.replace('xgrid', 'grid'): v for k, v in style_items if 'xgrid' in k}
ygrid = {k.replace('ygrid', 'grid'): v for k, v in style_items if 'ygrid' in k}
xopts = {k.replace('grid_', '') if any(r in k for r in replace) else k: v
Expand Down Expand Up @@ -1883,9 +1883,6 @@ class ColorbarPlot(ElementPlot):
True, uses 2nd and 98th percentile; otherwise uses the specified
numerical percentile value.""")

cformatter = param.ClassSelector(
default=None, class_=(str, TickFormatter, FunctionType), doc="""
Formatter for ticks along the colorbar axis.""")

cnorm = param.ObjectSelector(default='linear', objects=['linear', 'log', 'eq_hist'], doc="""
Color normalization to be applied during colormapping.""")
Expand Down
17 changes: 11 additions & 6 deletions holoviews/plotting/mpl/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,12 +845,17 @@ class BarPlot(BarsMixin, ColorbarPlot, LegendPlot):

_nonvectorized_styles = ['visible']

legend_specs = dict(LegendPlot.legend_specs, **{
'top': dict(bbox_to_anchor=(0., 1.02, 1., .102),
ncol=3, loc=3, mode="expand", borderaxespad=0.),
'bottom': dict(ncol=3, mode="expand", loc=2,
bbox_to_anchor=(0., -0.4, 1., .102),
borderaxespad=0.1)})
legend_specs = dict(
LegendPlot.legend_specs,
top=dict(
bbox_to_anchor=(0., 1.02, 1., .102),
ncol=3, loc=3, mode="expand", borderaxespad=0.
),
bottom=dict(
bbox_to_anchor=(0., -0.4, 1., .102),
ncol=3, loc=2, mode="expand", borderaxespad=0.1
)
)

def _get_values(self, element, ranges):
"""
Expand Down
1 change: 0 additions & 1 deletion holoviews/plotting/mpl/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ def _finalize_artist(self, element):
Allows extending the _finalize_axis method with Element
specific options.
"""
pass

def _set_labels(self, axes, dimensions, xlabel=None, ylabel=None, zlabel=None):
"""
Expand Down
1 change: 0 additions & 1 deletion holoviews/plotting/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ def _get_frame(self, key):
Required on each MPLPlot type to get the data corresponding
just to the current frame out from the object.
"""
pass

def matches(self, spec):
"""
Expand Down
1 change: 0 additions & 1 deletion holoviews/plotting/plotly/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ class BarPlot(BarsMixin, ElementPlot):
show_legend = param.Boolean(default=True, doc="""
Whether to show legend for the plot.""")

stacked = param.Boolean(default=False)

style_opts = ['visible']

Expand Down
4 changes: 2 additions & 2 deletions holoviews/plotting/plotly/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_layout_ranges(plot):
layout_ranges = {}
fig_dict = plot.state
for k in fig_dict['layout']:
if k.startswith('xaxis') or k.startswith('yaxis'):
if k.startswith(("xaxis", "yaxis")):
if "range" in fig_dict['layout'][k]:
layout_ranges[k] = {"range": fig_dict['layout'][k]["range"]}

Expand Down Expand Up @@ -87,7 +87,7 @@ def plot_to_figure(
# Remove range specification so plotly.js autorange + uirevision is in control
if layout_ranges and use_ranges:
for k in fig_dict['layout']:
if k.startswith('xaxis') or k.startswith('yaxis'):
if k.startswith(("xaxis", "yaxis")):
fig_dict['layout'][k].pop('range', None)
if k.startswith('mapbox'):
fig_dict['layout'][k].pop('zoom', None)
Expand Down
3 changes: 0 additions & 3 deletions holoviews/plotting/plotly/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ class LayoutPlot(PlotlyPlot, GenericLayoutPlot):

adjoint_spacing = param.Number(default=20, bounds=(0, None))

shared_axes = param.Boolean(default=True, doc="""
Whether axes should be shared across plots""")

shared_axes = param.Boolean(default=True, doc="""
Whether axes ranges should be shared across the layout, if
disabled switches axiswise normalization option on globally.""")
Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/plotly/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def plot_options(cls, obj, percent_size):
options = plot.lookup_options(obj, 'plot').options
width = options.get('width', plot.width) * factor
height = options.get('height', plot.height) * factor
return dict(options, **{'width':int(width), 'height': int(height)})
return dict(options, width=int(width), height=int(height))


@classmethod
Expand Down
2 changes: 1 addition & 1 deletion holoviews/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# Types supported by Pointer derived streams
pointer_types = (Number, str, tuple)+util.datetime_types

class _SkipTrigger(): pass
class _SkipTrigger: pass


@contextmanager
Expand Down
2 changes: 1 addition & 1 deletion holoviews/tests/core/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def test_dataset_redim_with_alias_dframe(self):
redim_df = pd.DataFrame({'X': range(10), 'y': range(0,20,2)})
dataset_redim = Dataset(redim_df, kdims=['X'], vdims=['y'])
self.assertEqual(dataset.redim(**{'X-label':'X'}), dataset_redim)
self.assertEqual(dataset.redim(**{'x':'X'}), dataset_redim)
self.assertEqual(dataset.redim(x='X'), dataset_redim)

def test_dataset_mixed_type_range(self):
ds = Dataset((['A', 'B', 'C', None],), 'A')
Expand Down
6 changes: 4 additions & 2 deletions holoviews/tests/core/data/test_xarrayinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ def get_irregular_dataarray(self, invert_y=True):
attrs={'transform': (3, 0, 2, 0, -2, -2)})
xs, ys = (np.tile(x[:, np.newaxis], len(y)).T,
np.tile(y[:, np.newaxis], len(x)))
return da.assign_coords(**{'xc': xr.DataArray(xs, dims=('y','x')),
'yc': xr.DataArray(ys, dims=('y','x')),})
return da.assign_coords(
xc=xr.DataArray(xs, dims=('y','x')),
yc=xr.DataArray(ys, dims=('y','x')),
)

def get_multi_dim_irregular_dataset(self):
temp = 15 + 8 * np.random.randn(2, 2, 4, 3)
Expand Down
2 changes: 1 addition & 1 deletion holoviews/tests/util/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def test_dataset_transform_by_spatial_select_expr_index_not_0_based():
)
spatial_expr = hv.dim('a', hv.element.selection.spatial_select, hv.dim('b'), geometry=geometry)
dataset = hv.Dataset(df)
df_out = dataset.transform(**{'flag': spatial_expr}).dframe()
df_out = dataset.transform(flag=spatial_expr).dframe()
expected_series = pd.Series(
{
101: False,
Expand Down
1 change: 0 additions & 1 deletion holoviews/util/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def update_options(cls, options, items):
Allows updating options depending on class attributes
and unvalidated options.
"""
pass

@classmethod
def get_options(cls, items, options, warnfn):
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ select = [
"FLY",
"ICN",
"NPY",
"PIE",
"PLC",
"PLE",
"PLR",
Expand All @@ -64,6 +65,7 @@ ignore = [
"PLR2004", # Magic value used in comparison
"PLW2901", # `for` loop variable is overwritten
"RUF005", # Consider {expr} instead of concatenation
"RUF012", # Mutable class attributes should use `typing.ClassVar`
]

fix = true
Expand Down

0 comments on commit ee37d1e

Please sign in to comment.