From 3383f006782d67da89735314b04efa5413d9b4e8 Mon Sep 17 00:00:00 2001 From: tkknight <2108488+tkknight@users.noreply.github.com> Date: Wed, 20 Dec 2023 13:17:48 +0000 Subject: [PATCH] ruff rule D211, D300, D403 compliance. (#5661) * git compliane for D300. * ruff compliance. * fix doctests. --- .ruff.toml | 3 --- benchmarks/benchmarks/aux_factory.py | 1 - benchmarks/benchmarks/cube.py | 1 - lib/iris/analysis/_scipy_interpolate.py | 1 - lib/iris/experimental/ugrid/mesh.py | 2 +- lib/iris/tests/test_analysis_calculus.py | 2 +- lib/iris/tests/test_coding_standards.py | 4 ++-- lib/iris/tests/test_coordsystem.py | 2 +- .../interpolation/test_RectilinearInterpolator.py | 4 +++- .../tests/unit/common/lenient/test__lenient_client.py | 8 ++++---- .../tests/unit/common/lenient/test__lenient_service.py | 8 ++++---- lib/iris/tests/unit/cube/test_Cube.py | 2 +- 12 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.ruff.toml b/.ruff.toml index f9e3770410..03fe7d4863 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -38,10 +38,7 @@ lint.ignore = [ "D202", # No blank lines allowed after function docstring "D205", # 1 blank line required between summary line and description "D209", # Multi-line docstring closing quotes should be on a separate line - "D211", # No blank lines allowed before class docstring - "D300", # triple double quotes `""" / Use triple single quotes `'''` "D401", # First line of docstring should be in imperative mood: ... - "D403", # First word of the first line should be capitalized "D404", # First word of the docstring should not be "This" "D405", # Section name should be properly capitalized "D406", # Section name should end with a newline diff --git a/benchmarks/benchmarks/aux_factory.py b/benchmarks/benchmarks/aux_factory.py index aed50c2854..c9881cf60e 100644 --- a/benchmarks/benchmarks/aux_factory.py +++ b/benchmarks/benchmarks/aux_factory.py @@ -18,7 +18,6 @@ class FactoryCommon: # * make class an ABC # * remove NotImplementedError # * combine setup_common into setup - """A base class running a generalised suite of benchmarks for any factory. Factory to be specified in a subclass. diff --git a/benchmarks/benchmarks/cube.py b/benchmarks/benchmarks/cube.py index 8fcea35499..67abe2577c 100644 --- a/benchmarks/benchmarks/cube.py +++ b/benchmarks/benchmarks/cube.py @@ -30,7 +30,6 @@ class ComponentCommon: # * make class an ABC # * remove NotImplementedError # * combine setup_common into setup - """A base class running a generalised suite of benchmarks for cubes that include a specified component (e.g. Coord, CellMeasure etc.). Component to be specified in a subclass. diff --git a/lib/iris/analysis/_scipy_interpolate.py b/lib/iris/analysis/_scipy_interpolate.py index bf1796f91e..251fb4bf70 100644 --- a/lib/iris/analysis/_scipy_interpolate.py +++ b/lib/iris/analysis/_scipy_interpolate.py @@ -40,7 +40,6 @@ def _ndim_coords_from_arrays(points, ndim=None): # source: https://github.com/scipy/scipy/blob/b94a5d5ccc08dddbc88453477ff2625\ # 9aeaafb32/scipy/interpolate/interpolate.py#L1400 class _RegularGridInterpolator: - """Interpolation on a regular grid in arbitrary dimensions. The data must be defined on a regular grid; the grid spacing however may be diff --git a/lib/iris/experimental/ugrid/mesh.py b/lib/iris/experimental/ugrid/mesh.py index 98fd08d643..14bb313474 100644 --- a/lib/iris/experimental/ugrid/mesh.py +++ b/lib/iris/experimental/ugrid/mesh.py @@ -2140,7 +2140,7 @@ def _add(self, coords): setattr(self, member_y, coords[1]) def add(self, node_x=None, node_y=None, edge_x=None, edge_y=None): - """use self.remove(edge_x=True) to remove a coordinate e.g., using the + """Use self.remove(edge_x=True) to remove a coordinate e.g., using the pattern self.add(edge_x=None) will not remove the edge_x coordinate. """ diff --git a/lib/iris/tests/test_analysis_calculus.py b/lib/iris/tests/test_analysis_calculus.py index 57c2414875..70c1077def 100644 --- a/lib/iris/tests/test_analysis_calculus.py +++ b/lib/iris/tests/test_analysis_calculus.py @@ -503,7 +503,7 @@ def build_cube(data, spherical=False): class TestCalculusWKnownSolutions(tests.IrisTest): def get_coord_pts(self, cube): - """return (x_pts, x_ones, y_pts, y_ones, z_pts, z_ones) for the given cube.""" + """Return (x_pts, x_ones, y_pts, y_ones, z_pts, z_ones) for the given cube.""" x = cube.coord(axis="X") y = cube.coord(axis="Y") z = cube.coord(axis="Z") diff --git a/lib/iris/tests/test_coding_standards.py b/lib/iris/tests/test_coding_standards.py index 78d6bd67e1..44bd2dc868 100644 --- a/lib/iris/tests/test_coding_standards.py +++ b/lib/iris/tests/test_coding_standards.py @@ -136,9 +136,9 @@ def test_categorised_warnings(): .. code-block:: python class _WarnComboCfDefaulting(IrisCfWarning, IrisDefaultingWarning): - \""" + \"\"\" One-off combination of warning classes - enhances user filtering. - \""" + \"\"\" pass """ diff --git a/lib/iris/tests/test_coordsystem.py b/lib/iris/tests/test_coordsystem.py index ea839cff00..69aeeaa1b1 100644 --- a/lib/iris/tests/test_coordsystem.py +++ b/lib/iris/tests/test_coordsystem.py @@ -250,7 +250,7 @@ def test_update_to_equivalent(self): class Test_GeogCS_mutation(tests.IrisTest): - "Test that altering attributes of a GeogCS instance behaves as expected." + """Test that altering attributes of a GeogCS instance behaves as expected.""" def test_semi_major_axis_change(self): # Clear datum diff --git a/lib/iris/tests/unit/analysis/interpolation/test_RectilinearInterpolator.py b/lib/iris/tests/unit/analysis/interpolation/test_RectilinearInterpolator.py index e02855513e..b37fa1de62 100644 --- a/lib/iris/tests/unit/analysis/interpolation/test_RectilinearInterpolator.py +++ b/lib/iris/tests/unit/analysis/interpolation/test_RectilinearInterpolator.py @@ -329,7 +329,9 @@ def test_fully_wrapped_not_circular(self): class Test___call___1D_singlelendim(ThreeDimCube): def setUp(self): - """thingness / (1) (wibble: 2; latitude: 1) + """Setup. + + thingness / (1) (wibble: 2; latitude: 1) Dimension coordinates: wibble x - latitude - x diff --git a/lib/iris/tests/unit/common/lenient/test__lenient_client.py b/lib/iris/tests/unit/common/lenient/test__lenient_client.py index a0c630bc21..54e2aca185 100644 --- a/lib/iris/tests/unit/common/lenient/test__lenient_client.py +++ b/lib/iris/tests/unit/common/lenient/test__lenient_client.py @@ -76,9 +76,9 @@ def myclient(*args, **kwargs): def test_call_naked_doc(self): @_lenient_client def myclient(): - """myclient doc-string.""" + """Myclient doc-string.""" - self.assertEqual(myclient.__doc__, "myclient doc-string.") + self.assertEqual(myclient.__doc__, "Myclient doc-string.") def test_call_no_kwargs(self): @_lenient_client() @@ -169,9 +169,9 @@ def myclient(*args, **kwargs): def test_call_doc(self): @_lenient_client() def myclient(): - """myclient doc-string.""" + """Myclient doc-string.""" - self.assertEqual(myclient.__doc__, "myclient doc-string.") + self.assertEqual(myclient.__doc__, "Myclient doc-string.") if __name__ == "__main__": diff --git a/lib/iris/tests/unit/common/lenient/test__lenient_service.py b/lib/iris/tests/unit/common/lenient/test__lenient_service.py index 6e53aeb952..a916779c79 100644 --- a/lib/iris/tests/unit/common/lenient/test__lenient_service.py +++ b/lib/iris/tests/unit/common/lenient/test__lenient_service.py @@ -67,9 +67,9 @@ def myservice(*args, **kwargs): def test_call_naked_doc(self): @_lenient_service def myservice(): - """myservice doc-string.""" + """Myservice doc-string.""" - self.assertEqual(myservice.__doc__, "myservice doc-string.") + self.assertEqual(myservice.__doc__, "Myservice doc-string.") def test_call(self): @_lenient_service() @@ -105,9 +105,9 @@ def myservice(*args, **kwargs): def test_call_doc(self): @_lenient_service() def myservice(): - """myservice doc-string.""" + """Myservice doc-string.""" - self.assertEqual(myservice.__doc__, "myservice doc-string.") + self.assertEqual(myservice.__doc__, "Myservice doc-string.") if __name__ == "__main__": diff --git a/lib/iris/tests/unit/cube/test_Cube.py b/lib/iris/tests/unit/cube/test_Cube.py index e883140121..27f1756770 100644 --- a/lib/iris/tests/unit/cube/test_Cube.py +++ b/lib/iris/tests/unit/cube/test_Cube.py @@ -961,7 +961,7 @@ class Test_slices_dim_order(tests.IrisTest): """ def setUp(self): - """setup a 4D iris cube, each dimension is length 1. + """Setup a 4D iris cube, each dimension is length 1. The dimensions are; dim1: time dim2: height