Skip to content

Commit 216d780

Browse files
committed
Unsafe automatic fixes
1 parent e9ecb9c commit 216d780

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+359
-122
lines changed

esmvalcore/_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def parse_resume(resume, recipe):
8080
return resume
8181

8282

83-
def process_recipe(recipe_file: Path, session):
83+
def process_recipe(recipe_file: Path, session) -> None:
8484
"""Process recipe."""
8585
import datetime
8686
import shutil
@@ -318,7 +318,7 @@ def _copy_config_file(
318318
in_file: Path,
319319
out_file: Path,
320320
overwrite: bool,
321-
):
321+
) -> None:
322322
"""Copy a configuration file."""
323323
import shutil
324324

esmvalcore/_provenance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def __init__(
139139
attributes: dict[str, Any] | None = None,
140140
ancestors: Iterable[TrackedFile] | None = None,
141141
prov_filename: str | None = None,
142-
):
142+
) -> None:
143143
"""Create an instance of a file with provenance tracking.
144144
145145
Arguments
@@ -182,7 +182,7 @@ def attributes(self) -> dict[str, Any]:
182182
return self._attributes
183183

184184
@attributes.setter
185-
def attributes(self, value: dict[str, Any] | None):
185+
def attributes(self, value: dict[str, Any] | None) -> None:
186186
"""Set attributes describing the file."""
187187
self._attributes = value
188188

esmvalcore/_recipe/from_datasets.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import itertools
66
import logging
77
import re
8-
from collections.abc import Iterable, Mapping, Sequence
8+
from collections.abc import Iterable, Mapping
99
from functools import partial
1010
from typing import TYPE_CHECKING, Any
1111

@@ -16,6 +16,7 @@
1616
from ._io import _load_recipe
1717

1818
if TYPE_CHECKING:
19+
from collections.abc import Sequence
1920
from pathlib import Path
2021

2122
from esmvalcore.dataset import Dataset
@@ -114,7 +115,7 @@ def _to_frozen(item):
114115
return item
115116

116117

117-
def _move_one_level_up(base: dict, level: str, target: str):
118+
def _move_one_level_up(base: dict, level: str, target: str) -> None:
118119
"""Move datasets one level up in the recipe."""
119120
groups = base[level]
120121
if not groups:

esmvalcore/_recipe/recipe.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from esmvalcore import __version__, esgf
1818
from esmvalcore._provenance import get_recipe_provenance
19-
from esmvalcore._task import BaseTask, DiagnosticTask, ResumeTask, TaskSet
19+
from esmvalcore._task import DiagnosticTask, ResumeTask, TaskSet
2020
from esmvalcore.config._config import TASKSEP
2121
from esmvalcore.config._dask import validate_dask_config
2222
from esmvalcore.config._diagnostics import TAGS
@@ -59,6 +59,7 @@
5959
if TYPE_CHECKING:
6060
from collections.abc import Iterable, Sequence
6161

62+
from esmvalcore._task import BaseTask
6263
from esmvalcore.config import Session
6364
from esmvalcore.io.protocol import DataElement
6465
from esmvalcore.typing import Facets

esmvalcore/_recipe/to_datasets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
import logging
6-
from collections.abc import Iterable, Iterator, Sequence
6+
from collections.abc import Iterable
77
from copy import deepcopy
88
from typing import TYPE_CHECKING, Any
99

@@ -23,6 +23,7 @@
2323
from ._io import _load_recipe
2424

2525
if TYPE_CHECKING:
26+
from collections.abc import Iterator, Sequence
2627
from pathlib import Path
2728

2829
from esmvalcore.config import Session

esmvalcore/_task.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""ESMValtool task definition."""
22

3+
from __future__ import annotations
4+
35
import abc
46
import contextlib
57
import datetime
@@ -810,11 +812,11 @@ def available_cpu_count() -> int:
810812
class TaskSet(set):
811813
"""Container for tasks."""
812814

813-
def flatten(self) -> "TaskSet":
815+
def flatten(self) -> TaskSet:
814816
"""Flatten the list of tasks."""
815817
return TaskSet(t for task in self for t in task.flatten())
816818

817-
def get_independent(self) -> "TaskSet":
819+
def get_independent(self) -> TaskSet:
818820
"""Return a set of independent tasks."""
819821
independent_tasks = TaskSet()
820822
all_tasks = self.flatten()

esmvalcore/cmor/_fixes/cmip5/ec_earth.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Fixes for EC-Earth model."""
22

3-
from collections.abc import Iterable
3+
from __future__ import annotations
4+
5+
from typing import TYPE_CHECKING
46

57
import iris
68
import numpy as np
@@ -12,6 +14,9 @@
1214
cube_to_aux_coord,
1315
)
1416

17+
if TYPE_CHECKING:
18+
from collections.abc import Iterable
19+
1520

1621
class Sic(Fix):
1722
"""Fixes for sic."""

esmvalcore/cmor/_fixes/cmip6/cesm2.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""Fixes for CESM2 model."""
22

3-
from pathlib import Path
3+
from __future__ import annotations
4+
45
from shutil import copyfile
6+
from typing import TYPE_CHECKING
57

68
import iris
79
import iris.coords
@@ -18,6 +20,9 @@
1820
fix_ocean_depth_coord,
1921
)
2022

23+
if TYPE_CHECKING:
24+
from pathlib import Path
25+
2126

2227
class Cl(Fix):
2328
"""Fixes for ``cl``."""

esmvalcore/cmor/_fixes/cmip6/e3sm_1_1.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
"""Fixes for E3SM-1-1 model."""
22

3-
from iris.cube import Cube
3+
from __future__ import annotations
4+
5+
from typing import TYPE_CHECKING
46

57
from esmvalcore.cmor.fix import Fix
68
from esmvalcore.preprocessor._shared import get_array_module
79

10+
if TYPE_CHECKING:
11+
from iris.cube import Cube
12+
813

914
def _mask_greater(cube: Cube, value: float) -> Cube:
1015
"""Mask all data of cube which is greater than ``value``."""

esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
"""Fixes for EC-Earth3-Veg-LR model."""
22

3-
from collections.abc import Sequence
3+
from __future__ import annotations
44

5-
import iris.cube
5+
from typing import TYPE_CHECKING
66

77
from esmvalcore.cmor._fixes.common import OceanFixGrid
88
from esmvalcore.cmor._fixes.fix import Fix
99

10+
if TYPE_CHECKING:
11+
from collections.abc import Sequence
12+
13+
import iris.cube
14+
1015

1116
class AllVars(Fix):
1217
"""Fixes for all variables."""

0 commit comments

Comments
 (0)