diff --git a/.flake8 b/.flake8 index 257b9b3d62..38cd1d82f7 100644 --- a/.flake8 +++ b/.flake8 @@ -26,8 +26,8 @@ exclude = .eggs, build, compiled_krb, - sphinxext, - tools, + docs/iris/src/sphinxext/*, + tools/*, # # ignore auto-generated files # diff --git a/docs/iris/gallery_tests/gallerytest_util.py b/docs/iris/gallery_tests/gallerytest_util.py index 38678fdb18..3ec18d0169 100644 --- a/docs/iris/gallery_tests/gallerytest_util.py +++ b/docs/iris/gallery_tests/gallerytest_util.py @@ -35,7 +35,7 @@ @contextlib.contextmanager def add_gallery_to_path(): """ - Creates a context manager which can be used to add the iris gallery + Creates a context manager which can be used to add the iris gallery to the PYTHONPATH. The gallery entries are only importable throughout the lifetime of this context manager. diff --git a/lib/iris/_concatenate.py b/lib/iris/_concatenate.py index 646613d114..32dc87d65b 100644 --- a/lib/iris/_concatenate.py +++ b/lib/iris/_concatenate.py @@ -9,7 +9,6 @@ """ from collections import defaultdict, namedtuple -from copy import deepcopy import dask.array as da import numpy as np diff --git a/lib/iris/analysis/_area_weighted.py b/lib/iris/analysis/_area_weighted.py index 06f44dc951..7ff5430ca6 100644 --- a/lib/iris/analysis/_area_weighted.py +++ b/lib/iris/analysis/_area_weighted.py @@ -4,10 +4,7 @@ # See COPYING and COPYING.LESSER in the root of the repository for full # licensing details. -import numpy as np - from iris.analysis._interpolation import get_xy_dim_coords, snapshot_grid -import iris import iris.experimental.regrid as eregrid diff --git a/lib/iris/analysis/_regrid.py b/lib/iris/analysis/_regrid.py index 0670c073ae..71584f04c0 100644 --- a/lib/iris/analysis/_regrid.py +++ b/lib/iris/analysis/_regrid.py @@ -426,8 +426,7 @@ def _get_horizontal_coord(cube, axis): if len(coords) != 1: raise ValueError( "Cube {!r} must contain a single 1D {} " - "coordinate.".format(cube.name()), - axis, + "coordinate.".format(cube.name(), axis) ) return coords[0] diff --git a/lib/iris/fileformats/name_loaders.py b/lib/iris/fileformats/name_loaders.py index 0d9d149664..0464eb37ed 100644 --- a/lib/iris/fileformats/name_loaders.py +++ b/lib/iris/fileformats/name_loaders.py @@ -882,7 +882,7 @@ def load_NAMEIII_timeseries(filename): for i, data_list in enumerate(data_lists): data_list.append(float(vals[i + 1])) - data_arrays = [np.array(l) for l in data_lists] + data_arrays = [np.array(dl) for dl in data_lists] time_array = np.array(time_list) tdim = NAMECoord(name="time", dimension=0, values=time_array) @@ -955,7 +955,7 @@ def load_NAMEII_timeseries(filename): for i, data_list in enumerate(data_lists): data_list.append(float(vals[i + 2])) - data_arrays = [np.array(l) for l in data_lists] + data_arrays = [np.array(dl) for dl in data_lists] time_array = np.array(time_list) tdim = NAMECoord(name="time", dimension=0, values=time_array) @@ -1111,7 +1111,7 @@ def load_NAMEIII_version2(filename): for i, data_list in enumerate(data_lists): data_list.append(float(vals[i + datacol1])) - data_arrays = [np.array(l) for l in data_lists] + data_arrays = [np.array(dl) for dl in data_lists] # Convert Z and T arrays into arrays of indices zind = [] diff --git a/lib/iris/fileformats/nimrod_load_rules.py b/lib/iris/fileformats/nimrod_load_rules.py index 7a0fd20fb9..4cf8755bb9 100644 --- a/lib/iris/fileformats/nimrod_load_rules.py +++ b/lib/iris/fileformats/nimrod_load_rules.py @@ -413,8 +413,8 @@ def coord_system(field, handle_metadata_errors): ) if any([is_missing(field, v) for v in crs_args]): warnings.warn( - f"Coordinate Reference System is not completely defined. " - f"Plotting and reprojection may be impaired." + "Coordinate Reference System is not completely defined. " + "Plotting and reprojection may be impaired." ) coord_sys = iris.coord_systems.TransverseMercator( *crs_args, iris.coord_systems.GeogCS(**ellipsoid), diff --git a/lib/iris/tests/unit/coords/test_CellMethod.py b/lib/iris/tests/unit/coords/test_CellMethod.py index 88906dd905..3014823f9f 100644 --- a/lib/iris/tests/unit/coords/test_CellMethod.py +++ b/lib/iris/tests/unit/coords/test_CellMethod.py @@ -84,7 +84,7 @@ def test_mixture_default(self): token = "air temperature" # includes space coord = AuxCoord(1, long_name=token) result = CellMethod(self.method, coords=[coord, token]) - expected = "{}: unknown, unknown".format(self.method, token, token) + expected = "{}: unknown, unknown".format(self.method) self.assertEqual(str(result), expected) diff --git a/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_build_auxiliary_coordinate.py b/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_build_auxiliary_coordinate.py index 70d72fb133..8734d883cd 100644 --- a/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_build_auxiliary_coordinate.py +++ b/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_build_auxiliary_coordinate.py @@ -68,7 +68,6 @@ def setUp(self): # Patch the deferred loading that prevents attempted file access. # This assumes that self.cf_bounds_var is defined in the test case. def patched__getitem__(proxy_self, keys): - variable = None for var in (self.cf_coord_var, self.cf_bounds_var): if proxy_self.variable_name == var.cf_name: return var[keys] diff --git a/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_build_mercator_coordinate_system.py b/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_build_mercator_coordinate_system.py index 2f02c71c9c..665beb8747 100644 --- a/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_build_mercator_coordinate_system.py +++ b/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_build_mercator_coordinate_system.py @@ -15,8 +15,6 @@ from unittest import mock -import numpy as np - import iris from iris.coord_systems import Mercator from iris.fileformats._pyke_rules.compiled_krb.fc_rules_cf_fc import \ diff --git a/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_build_stereographic_coordinate_system.py b/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_build_stereographic_coordinate_system.py index 8912614f96..e95f286a8d 100644 --- a/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_build_stereographic_coordinate_system.py +++ b/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_build_stereographic_coordinate_system.py @@ -15,8 +15,6 @@ from unittest import mock -import numpy as np - import iris from iris.coord_systems import Stereographic from iris.fileformats._pyke_rules.compiled_krb.fc_rules_cf_fc import \ diff --git a/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_has_supported_mercator_parameters.py b/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_has_supported_mercator_parameters.py index 1c167ec45d..4be7b04249 100644 --- a/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_has_supported_mercator_parameters.py +++ b/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_has_supported_mercator_parameters.py @@ -17,8 +17,6 @@ from unittest import mock -import numpy as np - from iris.fileformats._pyke_rules.compiled_krb.fc_rules_cf_fc import \ has_supported_mercator_parameters @@ -135,5 +133,6 @@ def test_invalid_false_northing(self): self.assertEqual(len(warns), 1) self.assertRegex(str(warns[0]), 'False northing') + if __name__ == "__main__": tests.main() diff --git a/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_has_supported_stereographic_parameters.py b/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_has_supported_stereographic_parameters.py index d02695f298..f528e22029 100644 --- a/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_has_supported_stereographic_parameters.py +++ b/lib/iris/tests/unit/fileformats/pyke_rules/compiled_krb/fc_rules_cf_fc/test_has_supported_stereographic_parameters.py @@ -17,9 +17,6 @@ from unittest import mock -import numpy as np - -from iris.coord_systems import Stereographic from iris.fileformats._pyke_rules.compiled_krb.fc_rules_cf_fc import \ has_supported_stereographic_parameters