Skip to content

Commit

Permalink
Merge branch 'main' into autoapi
Browse files Browse the repository at this point in the history
* main:
  ruff compliance for D106. (SciTools#5676)
  ruff complliance for rule D202. (SciTools#5674)
  nep29 drop numpy 1.22 (SciTools#5668)
  ruff compliance for D404. (SciTools#5671)
  ruff complliance for D406. (SciTools#5670)
  ruff compliance for D405 and D407 (SciTools#5666)
  Various ruff rule compliance (W, CPY, ISC, AIR) (SciTools#5667)
  • Loading branch information
tkknight committed Jan 3, 2024
2 parents e0e1c90 + cfa3644 commit b0427ee
Show file tree
Hide file tree
Showing 79 changed files with 3,369 additions and 3,363 deletions.
21 changes: 1 addition & 20 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ lint.ignore = [
# pycodestyle (E, W)
# https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
"E",
"W",

# mccabe (C90)
# https://docs.astral.sh/ruff/rules/#mccabe-c90
Expand All @@ -30,18 +29,12 @@ lint.ignore = [
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D104", # Missing docstring in public package
"D106", # Missing docstring in public nested class
# (D-3) Temporary, before an initial review, either fix ocurrenvces or move to (2).
# (D-3) Temporary, before an initial review, either fix ocurrences or move to (2).
"D100", # Missing docstring in public module
"D103", # Missing docstring in public function
"D200", # One-line docstring should fit on one line
"D202", # No blank lines allowed after function docstring
"D205", # 1 blank line required between summary line and description
"D401", # First line of docstring should be in imperative mood: ...
"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
"D407", # Missing dashed underline after section

# pyupgrade (UP)
# https://docs.astral.sh/ruff/rules/#pyupgrade-up
Expand Down Expand Up @@ -71,10 +64,6 @@ lint.ignore = [
# https://docs.astral.sh/ruff/rules/#flake8-builtins-a
"A",

# flake8-copyright (CPY)
# https://docs.astral.sh/ruff/rules/#flake8-copyright-cpy
"CPY",

# flake8-comprehensions (C4)
# https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
"C4",
Expand All @@ -91,10 +80,6 @@ lint.ignore = [
# https://docs.astral.sh/ruff/rules/#flake8-future-annotations-fa
"FA",

# flake8-implicit-str-concat (ISC)
# https://docs.astral.sh/ruff/rules/#flake8-implicit-str-concat-isc
"ISC",

# flake8-logging-format (G)
# https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
"G",
Expand Down Expand Up @@ -187,10 +172,6 @@ lint.ignore = [
# https://docs.astral.sh/ruff/rules/#flynt-fly
"FLY",

# Airflow (AIR)
# https://docs.astral.sh/ruff/rules/#airflow-air
"AIR",

# Perflint (PERF)
# https://docs.astral.sh/ruff/rules/#perflint-perf
"PERF",
Expand Down
3 changes: 0 additions & 3 deletions benchmarks/benchmarks/experimental/ugrid/regions_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def _make_region_cubes(self, full_mesh_cube):

def setup_cache(self):
"""Cache all the necessary source data on disk."""

# Control dask, to minimise memory usage + allow largest data.
self.fix_dask_settings()

Expand Down Expand Up @@ -106,7 +105,6 @@ def setup(self, n_cubesphere, imaginary_data=True, create_result_cube=True):
NOTE: various test classes override + extend this.
"""

# Load source cubes (full-mesh and regions)
with PARSE_UGRID_ON_LOAD.context():
self.full_mesh_cube = load_cube(
Expand Down Expand Up @@ -143,7 +141,6 @@ def fix_dask_settings(self):
which is optimised for space saving so we can test largest data.
"""

import dask.config as dcfg

# Use single-threaded, to avoid process-switching costs and minimise memory usage.
Expand Down
2 changes: 0 additions & 2 deletions benchmarks/benchmarks/generate_data/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def create_file__xios_2d_face_half_levels(
todo: is create_file__xios_2d_face_half_levels still appropriate now we can
properly save Mesh Cubes?
"""

return _create_file__xios_common(
func_name="create_file__xios_2d_face_half_levels",
dataset_name=dataset_name,
Expand All @@ -75,7 +74,6 @@ def create_file__xios_3d_face_half_levels(
todo: is create_file__xios_3d_face_half_levels still appropriate now we can
properly save Mesh Cubes?
"""

return _create_file__xios_common(
func_name="create_file__xios_3d_face_half_levels",
dataset_name=dataset_name,
Expand Down
3 changes: 0 additions & 3 deletions benchmarks/benchmarks/sperf/combine_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def _make_region_cubes(self, full_mesh_cube):

def setup_cache(self):
"""Cache all the necessary source data on disk."""

# Control dask, to minimise memory usage + allow largest data.
self.fix_dask_settings()

Expand Down Expand Up @@ -102,7 +101,6 @@ def setup(self, n_cubesphere, imaginary_data=True, create_result_cube=True):
NOTE: various test classes override + extend this.
"""

# Load source cubes (full-mesh and regions)
with PARSE_UGRID_ON_LOAD.context():
self.full_mesh_cube = load_cube(
Expand Down Expand Up @@ -142,7 +140,6 @@ def fix_dask_settings(self):
which is optimised for space saving so we can test largest data.
"""

import dask.config as dcfg

# Use single-threaded, to avoid process-switching costs and minimise memory usage.
Expand Down
5 changes: 2 additions & 3 deletions benchmarks/bm_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def _check_requirements(package: str) -> None:

def _prep_data_gen_env() -> None:
"""Create/access a separate, unchanging environment for generating test data."""

python_version = "3.11"
data_gen_var = "DATA_GEN_PYTHON"
if data_gen_var in environ:
Expand Down Expand Up @@ -257,8 +256,8 @@ def _gh_create_reports(commit_sha: str, results_full: str, results_shifts: str)
* commit {commit_sha} ({pr_tag}).
<p>
Please review the report below and
take corrective/congratulatory action as appropriate
Please review the report below and
take corrective/congratulatory action as appropriate
:slightly_smiling_face:
</p>
"""
Expand Down
6 changes: 3 additions & 3 deletions docs/gallery_code/general/plot_custom_file_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@


def load_NAME_III(filename):
"""Loads the Met Office's NAME III grid output files returning headers, column
"""Loads the Met Office's NAME III grid output files.
Loads the Met Office's NAME III grid output files returning headers, column
definitions and data arrays as 3 separate lists.
"""

# Loading a file gives a generator of lines which can be progressed using
# the next() function. This will come in handy as we wish to progress
# through the file line by line.
Expand Down Expand Up @@ -179,7 +180,6 @@ def load_NAME_III(filename):

def NAME_to_cube(filenames, callback):
"""Returns a generator of cubes given a list of filenames and a callback."""

for filename in filenames:
header, column_headings, data_arrays = load_NAME_III(filename)

Expand Down
5 changes: 1 addition & 4 deletions docs/gallery_code/meteorology/plot_COP_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@


def cop_metadata_callback(cube, field, filename):
"""A function which adds an "Experiment" coordinate which comes from the
filename.
"""

"""Function which adds an "Experiment" coordinate which comes from the filename."""
# Extract the experiment name (such as A1B or E1) from the filename (in
# this case it is just the start of the file name, before the first ".").
fname = os.path.basename(filename) # filename without path.
Expand Down
2 changes: 0 additions & 2 deletions docs/gallery_tests/test_gallery_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

def gallery_examples():
"""Generator to yield all current gallery examples."""

for example_file in GALLERY_DIR.glob("*/plot*.py"):
yield example_file.stem

Expand All @@ -30,7 +29,6 @@ def test_plot_example(
iris_future_defaults,
):
"""Test that all figures from example code match KGO."""

module = importlib.import_module(example)

# Run example.
Expand Down
18 changes: 10 additions & 8 deletions docs/src/developers_guide/documenting/docstrings_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ def __init__(self, arg1, arg2):
Description section text.
Args:
* arg1 (int):
Parameters
----------
arg1 : int
First argument description.
* arg2 (float):
arg2 : float
Second argument description.
Returns:
Boolean.
Returns
-------
bool
"""
self.a = arg1
Expand All @@ -26,8 +27,9 @@ def __init__(self, arg1, arg2):
def square(self):
"""*(read-only)* Purpose section description.
Returns:
int.
Returns
-------
int
"""
return self.a * self.a
19 changes: 9 additions & 10 deletions docs/src/developers_guide/documenting/docstrings_sample_routine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@ def sample_routine(arg1, arg2, kwarg1="foo", kwarg2=None):
Description section longer text goes here.
Args:
* arg1 (numpy.ndarray):
Parameters
----------
arg1 : numpy.ndarray
First argument description.
* arg2 (numpy.ndarray):
arg2 : numpy.ndarray
Second argument description.
Kwargs:
* kwarg1 (string):
kwarg1: str, optional
The first keyword argument. This argument description
can be multi-lined.
* kwarg2 (Boolean or None):
kwarg2 : bool, optional
The second keyword argument.
Returns:
Returns
-------
numpy.ndarray
numpy.ndarray of arg1 * arg2
"""
Expand Down
3 changes: 3 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ This document explains the changes made to Iris for this release
#. `@bjlittle`_ enforced the minimum pin of ``numpy>1.21`` in accordance with the `NEP29 Drop Schedule`_.
(:pull:`5525`)

#. `@bjlittle`_ enforced the minimum pin of ``numpy>1.22`` in accordance with the `NEP29 Drop Schedule`_.
(:pull:`5668`)


📚 Documentation
================
Expand Down

0 comments on commit b0427ee

Please sign in to comment.