diff --git a/.ruff.toml b/.ruff.toml index 13cbb685..3537cc52 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -1,11 +1,5 @@ extend = "pyproject.toml" -lint.ignore = [ - # flake8-self (SLF) - # https://docs.astral.sh/ruff/rules/#flake8-self-slf - "SLF001", # Private member accessed. -] - [lint.extend-per-file-ignores] "src/geovista/geoplotter.py" = [ # flake8-annotations (ANN) diff --git a/changelog/1216.contributor.rst b/changelog/1216.contributor.rst new file mode 100644 index 00000000..641ad5c3 --- /dev/null +++ b/changelog/1216.contributor.rst @@ -0,0 +1,2 @@ +Complied with `ruff `__ +``flake8-self`` (``SLF``) rules. (:user:`bjlittle`) diff --git a/pyproject.toml b/pyproject.toml index 4758da25..a8192848 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -269,6 +269,8 @@ max-statements = 91 # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann "ANN001", # Missing type annotation for function argument. "ANN201", # Missing return type annotation for public funciton. + # https://docs.astral.sh/ruff/rules/#flake8-self-slf + "SLF001", # flake8-self: Private member accessed. ] # TODO @bjlittle: investigate behaviour of commented-out failing test "tests/core/test_slice_lines.py" = [ diff --git a/src/geovista/cache/__init__.py b/src/geovista/cache/__init__.py index 84a1cb01..3860c037 100644 --- a/src/geovista/cache/__init__.py +++ b/src/geovista/cache/__init__.py @@ -90,14 +90,14 @@ # maintain the original Pooch.fetch method prior to wrapping # with user-agent headers version -CACHE._fetch = CACHE.fetch +CACHE._fetch = CACHE.fetch # noqa: SLF001 -@wraps(CACHE._fetch) +@wraps(CACHE._fetch) # noqa: SLF001 def _fetch(*args: str, **kwargs: bool | Callable) -> str: # numpydoc ignore=GL08 # default to our http/s downloader with user-agent headers kwargs.setdefault("downloader", _downloader) - return CACHE._fetch(*args, **kwargs) + return CACHE._fetch(*args, **kwargs) # noqa: SLF001 # override the original Pooch.fetch method with our diff --git a/src/geovista/common.py b/src/geovista/common.py index d7e296a3..45909d38 100644 --- a/src/geovista/common.py +++ b/src/geovista/common.py @@ -291,10 +291,10 @@ def cast_UnstructuredGrid_to_PolyData( # noqa: N802 raise TypeError(emsg) # see https://vtk.org/pipermail/vtkusers/2011-March/066506.html - alg = pv._vtk.vtkGeometryFilter() + alg = pv._vtk.vtkGeometryFilter() # noqa: SLF001 alg.AddInputData(mesh) alg.Update() - result = pv.core.filters._get_output(alg) + result = pv.core.filters._get_output(alg) # noqa: SLF001 if clean: result = result.clean() @@ -898,7 +898,7 @@ def triangulated(surface: pv.PolyData) -> bool: .. versionadded:: 0.1.0 """ - return np.all(np.diff(surface._offset_array) == 3) + return np.all(np.diff(surface._offset_array) == 3) # noqa: SLF001 def vtk_warnings_off() -> None: diff --git a/src/geovista/core.py b/src/geovista/core.py index a429c1dc..69e2b001 100644 --- a/src/geovista/core.py +++ b/src/geovista/core.py @@ -375,7 +375,7 @@ def combine( common_point_data = set(first.point_data.keys()) common_cell_data = set(first.cell_data.keys()) common_field_data = set(first.field_data.keys()) - active_scalars_info = {first.active_scalars_info._namedtuple} + active_scalars_info = {first.active_scalars_info._namedtuple} # noqa: SLF001 for i, mesh in enumerate(meshes): if not isinstance(mesh, pv.PolyData): @@ -404,12 +404,12 @@ def combine( if n_points: # compute the number of vertices (N) for each face of the mesh - faces_n = np.diff(mesh._offset_array) + faces_n = np.diff(mesh._offset_array) # noqa: SLF001 # determine the N offset for each face within the faces array # a face entry consists of (N, v1, v2, ..., vN), where vN is the Nth # vertex offset (connectivity) for that face into the associated mesh # points array - faces_n_offset = mesh._offset_array + np.arange(mesh._offset_array.size) + faces_n_offset = mesh._offset_array + np.arange(mesh._offset_array.size) # noqa: SLF001 # offset the current mesh connectivity by the cumulative mesh points count faces += n_points # reinstate N for each face entry @@ -425,7 +425,7 @@ def combine( common_cell_data &= set(mesh.cell_data.keys()) common_field_data &= set(mesh.field_data.keys()) if mesh.active_scalars_name: - active_scalars_info &= {mesh.active_scalars_info._namedtuple} + active_scalars_info &= {mesh.active_scalars_info._namedtuple} # noqa: SLF001 points = np.vstack(combined_points) faces = np.hstack(combined_faces) diff --git a/src/geovista/filters.py b/src/geovista/filters.py index 612a087e..c34b0ef2 100644 --- a/src/geovista/filters.py +++ b/src/geovista/filters.py @@ -143,7 +143,7 @@ def remesh( poly1.triangulate(inplace=True) # https://vtk.org/doc/nightly/html/classvtkIntersectionPolyDataFilter.html - alg = pv._vtk.vtkIntersectionPolyDataFilter() + alg = pv._vtk.vtkIntersectionPolyDataFilter() # noqa: SLF001 alg.SetInputDataObject(0, poly0) alg.SetInputDataObject(1, poly1) # BoundaryPoints (points) mask array @@ -154,7 +154,7 @@ def remesh( alg.SetSplitSecondOutput(False) # noqa: FBT003 alg.Update() - remeshed: pv.PolyData = pv.core.filters._get_output(alg, oport=1) + remeshed: pv.PolyData = pv.core.filters._get_output(alg, oport=1) # noqa: SLF001 if remeshed.n_cells == 0: # no remeshing has been performed as the meridian does not intersect the mesh diff --git a/tests/plotting/__init__.py b/tests/plotting/__init__.py index 79bc42f9..339e6b8c 100644 --- a/tests/plotting/__init__.py +++ b/tests/plotting/__init__.py @@ -23,7 +23,7 @@ CI: bool = os.environ.get("CI", "false").lower() == "true" # prepare geovista/pyvista for off-screen image testing -pv.global_theme.load_theme(pv.plotting.themes._TestingTheme()) +pv.global_theme.load_theme(pv.plotting.themes._TestingTheme()) # noqa: SLF001 pv.global_theme.window_size = [450, 300] pv.OFF_SCREEN = True gv.GEOVISTA_IMAGE_TESTING = True