From 253687d45d23cba362df13c092382be51bf10690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Thu, 10 Aug 2023 11:45:28 +0200 Subject: [PATCH] Update pre-commit (#668) --- .pre-commit-config.yaml | 2 +- geoviews/data/geom_dict.py | 2 +- geoviews/element/geo.py | 4 ++-- pyproject.toml | 13 ++++++++++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bab6400a..74635594 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: trailing-whitespace exclude: \.svg$ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.276 + rev: v0.0.283 hooks: - id: ruff args: [geoviews] diff --git a/geoviews/data/geom_dict.py b/geoviews/data/geom_dict.py index f3b069bd..0d22091a 100644 --- a/geoviews/data/geom_dict.py +++ b/geoviews/data/geom_dict.py @@ -223,7 +223,7 @@ def select(cls, dataset, selection_mask=None, **selection): new_data[k] = v else: new_data[k] = v[selection_mask] - if indexed and len(list(new_data.values())[0]) == 1 and len(dataset.vdims) == 1: + if indexed and len(next(iter(new_data.values()))) == 1 and len(dataset.vdims) == 1: value = new_data[dataset.vdims[0].name] return value if isscalar(value) else value[0] return new_data diff --git a/geoviews/element/geo.py b/geoviews/element/geo.py index 18da9368..99bc40ec 100644 --- a/geoviews/element/geo.py +++ b/geoviews/element/geo.py @@ -996,8 +996,8 @@ def from_records(cls, records, dataset=None, on=None, value=None, vdims = dataset.vdims ddims = dataset.dimensions() if None in vdims: - raise ValueError('Value dimension {} not found ' - 'in dataset dimensions {}'.format(value, ddims) ) + raise ValueError(f'Value dimension {value} not found ' + f'in dataset dimensions {ddims}' ) else: vdims = [] diff --git a/pyproject.toml b/pyproject.toml index 41608c73..fc057a2c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,10 @@ target-version = "py38" select = [ "E", "F", + "FLY", "ICN", + "NPY", + "PIE", "PLC", "PLE", "PLR", @@ -32,11 +35,12 @@ ignore = [ "E731", # Do not assign a lambda expression, use a def "E741", # Ambiguous variable name "F405", # From star imports + "PLC1901", # empty string is falsey "PLE0604", # Invalid object in `__all__`, must contain only strings - "PLE0605", # Invalid format for __all__ + "PLE0605", # Invalid format for `__all__` "PLR091", # Too many arguments/branches/statements "PLR2004", # Magic value used in comparison - "PLW2901", # For loop variable overwritten + "PLW2901", # `for` loop variable is overwritten "RUF005", # Consider {expr} instead of concatenation "RUF012", # Mutable class attributes should use `typing.ClassVar` ] @@ -48,7 +52,10 @@ unfixable = [ [tool.ruff.per-file-ignores] "__init__.py" = ["F403"] -"geoviews/tests/*" = ["RUF001", "RUF002", "RUF003"] # Ambiguous unicode character +"geoviews/tests/*" = [ + "RUF001", "RUF002", "RUF003", # Ambiguous unicode character + "NPY002", # Replace legacy `np.random.rand` call with Generator +] [tool.codespell] ignore-words-list = "lod,nd"