From 406a35edddcf371b62f75576c182bffa03457766 Mon Sep 17 00:00:00 2001
From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com>
Date: Fri, 26 Jan 2024 11:19:21 -0500
Subject: [PATCH 1/8] autoupdate pre-commit, pin formatters to pre-commit
versions
---
.pre-commit-config.yaml | 6 +++---
pyproject.toml | 9 +++++----
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index bbc5cde4f..992dee29f 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -33,7 +33,7 @@ repos:
- id: yamllint
args: [ '--config-file=.yamllint.yaml' ]
- repo: https://github.com/psf/black-pre-commit-mirror
- rev: 23.12.1
+ rev: 24.1.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
@@ -41,7 +41,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.1.13
+ rev: v0.1.14
hooks:
- id: ruff
- repo: https://github.com/pylint-dev/pylint
@@ -61,7 +61,7 @@ repos:
- id: nbqa-pyupgrade
args: [ '--py38-plus' ]
- id: nbqa-black
- additional_dependencies: [ 'black==23.12.1' ]
+ additional_dependencies: [ 'black==24.1.0' ]
- id: nbqa-isort
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
diff --git a/pyproject.toml b/pyproject.toml
index fe5c6958e..2f713b377 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -59,9 +59,9 @@ dependencies = [
[project.optional-dependencies]
dev = [
# Dev tools and testing
- "black >=23.3.0",
- "blackdoc",
- "bump-my-version",
+ "black ==24.1.0",
+ "blackdoc ==0.3.9",
+ "bump-my-version >=0.17.1",
"codespell",
"coverage[toml]",
"flake8",
@@ -69,6 +69,7 @@ dev = [
"flake8-rst-docstrings",
"h5netcdf",
"ipython",
+ "isort ==5.13.2",
"mypy",
"nbqa",
"nbval",
@@ -83,7 +84,7 @@ dev = [
"pytest-xdist[psutil] >=3.2",
"ruff >=0.1.0",
"tokenize-rt",
- "tox",
+ "tox >=4.0",
# "tox-conda", # Will be added when a tox@v4.0+ compatible plugin is released.
"xdoctest",
"yamllint",
From 78b0c336294af84d8379821f633a37aae33ea30e Mon Sep 17 00:00:00 2001
From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com>
Date: Fri, 26 Jan 2024 11:22:48 -0500
Subject: [PATCH 2/8] pin conda formatting tools to pre-commit versions
---
environment.yml | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/environment.yml b/environment.yml
index 48f96f614..d08704a51 100644
--- a/environment.yml
+++ b/environment.yml
@@ -29,9 +29,9 @@ dependencies:
# Extras
- flox
# Testing and development dependencies
- - black >=22.12
- - blackdoc
- - bump-my-version
+ - black ==24.1.0
+ - blackdoc ==0.3.9
+# - bump-my-version # The conda package is not as up-to-date as the PyPI package.
- cairosvg
- codespell
- coverage
@@ -43,6 +43,7 @@ dependencies:
- h5netcdf
- ipykernel
- ipython
+ - isort ==5.13.2
- matplotlib
- mypy
- nbqa
@@ -68,11 +69,12 @@ dependencies:
- sphinx-rtd-theme >=1.0
- sphinxcontrib-bibtex
- tokenize-rt
- - tox
+ - tox >=4.0
# - tox-conda # Will be added when a tox@v4.0+ compatible plugin is released.
- xdoctest
- yamllint
- pip
- pip:
+ - bump-my-version >=0.17.1 # The conda package is not as up-to-date as the PyPI package.
- flake8-alphabetize
- sphinxcontrib-svg2pdfconverter
From a2368421b0e9c3c0b0f397164e5fdb03aaa30664 Mon Sep 17 00:00:00 2001
From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com>
Date: Fri, 26 Jan 2024 11:34:42 -0500
Subject: [PATCH 3/8] update CHANGES.rst
---
CHANGES.rst | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGES.rst b/CHANGES.rst
index 4f46a4419..e5f13f1d9 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -25,6 +25,7 @@ Breaking changes
* `xclim`'s units registry and units formatting are now extended from `cf-xarray`. The exponent sign "^" is now never added in the ``units`` attribute. For example, square meters are given as "m2" instead of "m^2" by xclim, both are still accepted as input. (:issue:`1010`, :pull:`1590`).
* `yamale` is now listed as a core dependency (was previously listed in the `dev` installation recipe). (:issue:`1595`, :pull:`1596`).
* Due to a licensing limitation, the calculation of empirical orthogonal function based on `eofs` (``xclim.sdba.properties.first_eof``) has been removed from `xclim`. (:issue:`1620`, :pull:`1621`).
+* `black` formatting style has been updated to the 2024 stable conventions. `isort` has been added to the `dev` installation recipe.
Bug fixes
^^^^^^^^^
@@ -47,6 +48,7 @@ Internal changes
* A new GitHub Workflow (``workflow-warning.yml``) has been added to warn maintainers when a forked repository has been used to open a Pull Request that modifies GitHub Workflows.
* `pylint` has been configured to provide some overhead checks of the `xclim` codebase as well as run as part of `xclim`'s `pre-commit` hooks.
* Some small adjustments to code organization to address `pylint` errors.
+* `dev` formatting tools (`black`, `blackdoc`, `isort`) are now pinned to their `pre-commit` hook version equivalents.
v0.47.0 (2023-12-01)
--------------------
From 105f451a2669e75aee63a4ef905e3ee71fd69845 Mon Sep 17 00:00:00 2001
From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com>
Date: Fri, 26 Jan 2024 11:47:45 -0500
Subject: [PATCH 4/8] pin tox code formatting versions
---
CHANGES.rst | 2 +-
tox.ini | 11 +++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index e5f13f1d9..85792c664 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -48,7 +48,7 @@ Internal changes
* A new GitHub Workflow (``workflow-warning.yml``) has been added to warn maintainers when a forked repository has been used to open a Pull Request that modifies GitHub Workflows.
* `pylint` has been configured to provide some overhead checks of the `xclim` codebase as well as run as part of `xclim`'s `pre-commit` hooks.
* Some small adjustments to code organization to address `pylint` errors.
-* `dev` formatting tools (`black`, `blackdoc`, `isort`) are now pinned to their `pre-commit` hook version equivalents.
+* `dev` formatting tools (`black`, `blackdoc`, `isort`) are now pinned to their `pre-commit` hook version equivalents in both `pyproject.toml` and `tox.ini`.
v0.47.0 (2023-12-01)
--------------------
diff --git a/tox.ini b/tox.ini
index 39f6b6694..e226d8da4 100644
--- a/tox.ini
+++ b/tox.ini
@@ -21,13 +21,15 @@ description = Run code quality compliance tests under {basepython}
skip_install = True
extras =
deps =
+ codespell
flake8
+ flake8-alphabetize
flake8-rst-docstrings
- black[jupyter]
- blackdoc
- isort
+ black[jupyter]==24.1.0
+ blackdoc==0.3.9
+ isort==5.13.2
nbqa
- ruff
+ ruff>=0.1.0
yamllint
commands_pre =
commands =
@@ -38,6 +40,7 @@ commands =
nbqa black --check docs
blackdoc --check --exclude=xclim/indices/__init__.py xclim
blackdoc --check docs
+ codespell xclim tests docs
yamllint --config-file=.yamllint.yaml xclim
commands_post =
From 5bdd214bb515c97d6ccb9fd6b253b85d3b32ffc6 Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Fri, 26 Jan 2024 16:51:53 +0000
Subject: [PATCH 5/8] [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---
docs/autodoc_indicator.py | 1 +
tests/test_generic.py | 1 +
tests/test_land.py | 1 +
tests/test_stats.py | 1 +
xclim/__init__.py | 1 +
xclim/analog.py | 1 +
xclim/cli.py | 1 +
xclim/core/__init__.py | 1 +
xclim/core/bootstrapping.py | 1 +
xclim/core/calendar.py | 23 ++++++++++++++---------
xclim/core/cfchecks.py | 1 +
xclim/core/datachecks.py | 1 +
xclim/core/dataflags.py | 1 +
xclim/core/formatting.py | 1 +
xclim/core/indicator.py | 9 ++++++---
xclim/core/locales.py | 1 +
xclim/core/missing.py | 1 +
xclim/core/options.py | 1 +
xclim/core/units.py | 1 +
xclim/core/utils.py | 7 ++++---
xclim/ensembles/__init__.py | 1 +
xclim/ensembles/_base.py | 7 ++++---
xclim/ensembles/_reduce.py | 13 +++++++------
xclim/ensembles/_robustness.py | 1 +
xclim/indicators/__init__.py | 1 +
xclim/indicators/atmos/__init__.py | 1 +
xclim/indicators/atmos/_conversion.py | 1 +
xclim/indicators/atmos/_precip.py | 1 +
xclim/indicators/atmos/_synoptic.py | 1 +
xclim/indicators/atmos/_temperature.py | 1 +
xclim/indicators/generic/__init__.py | 1 +
xclim/indicators/land/__init__.py | 1 +
xclim/indicators/land/_streamflow.py | 1 +
xclim/indicators/seaIce/__init__.py | 1 +
xclim/indicators/seaIce/_seaice.py | 1 +
xclim/indices/__init__.py | 1 +
xclim/indices/fire/_cffwis.py | 6 ++++--
xclim/indices/generic.py | 1 +
xclim/indices/helpers.py | 1 +
xclim/indices/run_length.py | 1 +
xclim/indices/stats.py | 1 +
xclim/sdba/__init__.py | 1 +
xclim/sdba/_adjustment.py | 1 +
xclim/sdba/_processing.py | 1 +
xclim/sdba/base.py | 1 +
xclim/sdba/detrending.py | 1 +
xclim/sdba/loess.py | 1 +
xclim/sdba/measures.py | 1 +
xclim/sdba/utils.py | 1 +
xclim/testing/__init__.py | 1 +
xclim/testing/helpers.py | 1 +
xclim/testing/sdba_utils.py | 1 +
xclim/testing/utils.py | 1 +
53 files changed, 86 insertions(+), 26 deletions(-)
diff --git a/docs/autodoc_indicator.py b/docs/autodoc_indicator.py
index b16fa2e2e..f87ba40ed 100644
--- a/docs/autodoc_indicator.py
+++ b/docs/autodoc_indicator.py
@@ -4,6 +4,7 @@
Based on https://github.com/powerline/powerline/blob/83d855d3d73498c47553afeba212415990d95c54/docs/source/powerline_autodoc.py
"""
+
from __future__ import annotations
from sphinx.domains.python import PyFunction, PyXRefRole
diff --git a/tests/test_generic.py b/tests/test_generic.py
index 21a4f9394..2550d8ec2 100644
--- a/tests/test_generic.py
+++ b/tests/test_generic.py
@@ -1,4 +1,5 @@
"""Tests for generic indices."""
+
from __future__ import annotations
import numpy as np
diff --git a/tests/test_land.py b/tests/test_land.py
index f1349da3c..4418aa2fc 100644
--- a/tests/test_land.py
+++ b/tests/test_land.py
@@ -1,4 +1,5 @@
"""Tests for indicators in `land` realm."""
+
from __future__ import annotations
import numpy as np
diff --git a/tests/test_stats.py b/tests/test_stats.py
index 2a3a04bcd..091c95fc7 100644
--- a/tests/test_stats.py
+++ b/tests/test_stats.py
@@ -1,4 +1,5 @@
"""Tests for statistical indices."""
+
from __future__ import annotations
import numpy as np
diff --git a/xclim/__init__.py b/xclim/__init__.py
index 2b7317469..20948d12d 100644
--- a/xclim/__init__.py
+++ b/xclim/__init__.py
@@ -1,4 +1,5 @@
"""Climate indices computation package based on Xarray."""
+
from __future__ import annotations
try:
diff --git a/xclim/analog.py b/xclim/analog.py
index 1adeb2ff1..01d12a7e2 100644
--- a/xclim/analog.py
+++ b/xclim/analog.py
@@ -1,4 +1,5 @@
"""Spatial Analogues module."""
+
# TODO: Hellinger distance
# TODO: Mahalanobis distance
# TODO: Comment on "significance" of results.
diff --git a/xclim/cli.py b/xclim/cli.py
index 601292c6b..e6d8fec6f 100644
--- a/xclim/cli.py
+++ b/xclim/cli.py
@@ -3,6 +3,7 @@
Command Line Interface module
=============================
"""
+
from __future__ import annotations
import sys
diff --git a/xclim/core/__init__.py b/xclim/core/__init__.py
index a5a829efb..48c0ffb8a 100644
--- a/xclim/core/__init__.py
+++ b/xclim/core/__init__.py
@@ -1,4 +1,5 @@
"""Core module."""
+
from __future__ import annotations
from . import missing
diff --git a/xclim/core/bootstrapping.py b/xclim/core/bootstrapping.py
index be5136b61..2d7009208 100644
--- a/xclim/core/bootstrapping.py
+++ b/xclim/core/bootstrapping.py
@@ -1,4 +1,5 @@
"""Module comprising the bootstrapping algorithm for indicators."""
+
from __future__ import annotations
import warnings
diff --git a/xclim/core/calendar.py b/xclim/core/calendar.py
index e63d4ac21..69ca736b5 100644
--- a/xclim/core/calendar.py
+++ b/xclim/core/calendar.py
@@ -4,6 +4,7 @@
Helper function to handle dates, times and different calendars with xarray.
"""
+
from __future__ import annotations
import datetime as pydt
@@ -1013,12 +1014,14 @@ def resample_doy(doy: xr.DataArray, arr: xr.DataArray | xr.Dataset) -> xr.DataAr
def time_bnds( # noqa: C901
- time: xr.DataArray
- | xr.Dataset
- | CFTimeIndex
- | pd.DatetimeIndex
- | DataArrayResample
- | DatasetResample,
+ time: (
+ xr.DataArray
+ | xr.Dataset
+ | CFTimeIndex
+ | pd.DatetimeIndex
+ | DataArrayResample
+ | DatasetResample
+ ),
freq: str | None = None,
precision: str | None = None,
):
@@ -1768,9 +1771,11 @@ def stack_periods(
periods.append(
slice(
strd_slc.start + win_slc.start,
- (strd_slc.start + win_slc.stop)
- if win_slc.stop is not None
- else da.time.size,
+ (
+ (strd_slc.start + win_slc.stop)
+ if win_slc.stop is not None
+ else da.time.size
+ ),
)
)
diff --git a/xclim/core/cfchecks.py b/xclim/core/cfchecks.py
index 6a4d1e971..c993c0056 100644
--- a/xclim/core/cfchecks.py
+++ b/xclim/core/cfchecks.py
@@ -4,6 +4,7 @@
Utilities designed to verify the compliance of metadata with the CF-Convention.
"""
+
from __future__ import annotations
import fnmatch
diff --git a/xclim/core/datachecks.py b/xclim/core/datachecks.py
index f1dba1e5e..1e3b6e6dc 100644
--- a/xclim/core/datachecks.py
+++ b/xclim/core/datachecks.py
@@ -4,6 +4,7 @@
Utilities designed to check the validity of data inputs.
"""
+
from __future__ import annotations
from typing import Sequence
diff --git a/xclim/core/dataflags.py b/xclim/core/dataflags.py
index 86f0606a0..e14d4a0ea 100644
--- a/xclim/core/dataflags.py
+++ b/xclim/core/dataflags.py
@@ -4,6 +4,7 @@
Pseudo-indicators designed to analyse supplied variables for suspicious/erroneous indicator values.
"""
+
from __future__ import annotations
from decimal import Decimal
diff --git a/xclim/core/formatting.py b/xclim/core/formatting.py
index 4f9c7fd01..b3a90516c 100644
--- a/xclim/core/formatting.py
+++ b/xclim/core/formatting.py
@@ -2,6 +2,7 @@
Formatting Utilities for Indicators
===================================
"""
+
from __future__ import annotations
import datetime as dt
diff --git a/xclim/core/indicator.py b/xclim/core/indicator.py
index 1bc57b63f..d1698ffee 100644
--- a/xclim/core/indicator.py
+++ b/xclim/core/indicator.py
@@ -97,6 +97,7 @@
to one of those official variables.
"""
+
from __future__ import annotations
import re
@@ -1755,9 +1756,11 @@ def build_indicator_module_from_yaml( # noqa: C901
elif translations is not None:
# A mapping was passed, we read paths is any.
translations = {
- lng: read_locale_file(trans, module=module_name, encoding=encoding)
- if isinstance(trans, (str, Path))
- else trans
+ lng: (
+ read_locale_file(trans, module=module_name, encoding=encoding)
+ if isinstance(trans, (str, Path))
+ else trans
+ )
for lng, trans in translations.items()
}
diff --git a/xclim/core/locales.py b/xclim/core/locales.py
index 705ab0881..db53d62f4 100644
--- a/xclim/core/locales.py
+++ b/xclim/core/locales.py
@@ -43,6 +43,7 @@
For xclim-provided translations (for now only French), all indicators must have en entry and the "attrs_mapping"
entries must match exactly the default formatter. Those default translations are found in the `xclim/locales` folder.
"""
+
from __future__ import annotations
import json
diff --git a/xclim/core/missing.py b/xclim/core/missing.py
index 1eb95eebc..865450b12 100644
--- a/xclim/core/missing.py
+++ b/xclim/core/missing.py
@@ -22,6 +22,7 @@
To define another missing value algorithm, subclass :py:class:`MissingBase` and decorate it with
:py:func:`xclim.core.options.register_missing_method`.
"""
+
from __future__ import annotations
import numpy as np
diff --git a/xclim/core/options.py b/xclim/core/options.py
index 1eba36a3f..556a9cc96 100644
--- a/xclim/core/options.py
+++ b/xclim/core/options.py
@@ -4,6 +4,7 @@
Global or contextual options for xclim, similar to xarray.set_options.
"""
+
from __future__ import annotations
from inspect import signature
diff --git a/xclim/core/units.py b/xclim/core/units.py
index 185f6726a..a23b385af 100644
--- a/xclim/core/units.py
+++ b/xclim/core/units.py
@@ -5,6 +5,7 @@
`xclim`'s `pint`-based unit registry is an extension of the registry defined in `cf-xarray`.
This module defines most unit handling methods.
"""
+
from __future__ import annotations
import logging
diff --git a/xclim/core/utils.py b/xclim/core/utils.py
index d582b5be2..00e6e2c92 100644
--- a/xclim/core/utils.py
+++ b/xclim/core/utils.py
@@ -4,6 +4,7 @@
Helper functions for the indices computations, indicator construction and other things.
"""
+
from __future__ import annotations
import functools
@@ -806,9 +807,9 @@ def adapt_clix_meta_yaml( # noqa: C901
),
"units": param["units"],
}
- rename_params[
- f"{{{name}}}"
- ] = f"{{{list(param['data'].keys())[0]}}}"
+ rename_params[f"{{{name}}}"] = (
+ f"{{{list(param['data'].keys())[0]}}}"
+ )
else:
# Value
data["parameters"][name] = f"{param['data']} {param['units']}"
diff --git a/xclim/ensembles/__init__.py b/xclim/ensembles/__init__.py
index 9144811cb..a6a0c1f82 100644
--- a/xclim/ensembles/__init__.py
+++ b/xclim/ensembles/__init__.py
@@ -7,6 +7,7 @@
In xclim, an "ensemble" is a `Dataset` or a `DataArray` where multiple climate realizations
or models are concatenated along the `realization` dimension.
"""
+
from __future__ import annotations
from ._base import create_ensemble, ensemble_mean_std_max_min, ensemble_percentiles
diff --git a/xclim/ensembles/_base.py b/xclim/ensembles/_base.py
index db7dc1d8f..8443f1347 100644
--- a/xclim/ensembles/_base.py
+++ b/xclim/ensembles/_base.py
@@ -2,6 +2,7 @@
Ensembles Creation and Statistics
=================================
"""
+
from __future__ import annotations
from glob import glob
@@ -277,9 +278,9 @@ def ensemble_percentiles(
# Smart rechunk on dimension where chunks are the largest
chk_dim, chks = max(
enumerate(ens.chunks),
- key=lambda kv: 0
- if kv[0] == ens.get_axis_num("realization")
- else max(kv[1]),
+ key=lambda kv: (
+ 0 if kv[0] == ens.get_axis_num("realization") else max(kv[1])
+ ),
)
ens = ens.chunk(
{"realization": -1, ens.dims[chk_dim]: len(chks) * ens.realization.size}
diff --git a/xclim/ensembles/_reduce.py b/xclim/ensembles/_reduce.py
index c22e0b928..fd415ba10 100644
--- a/xclim/ensembles/_reduce.py
+++ b/xclim/ensembles/_reduce.py
@@ -5,6 +5,7 @@
Ensemble reduction is the process of selecting a subset of members from an ensemble in order to reduce the volume of
computation needed while still covering a good portion of the simulated climate variability.
"""
+
from __future__ import annotations
from warnings import warn
@@ -88,9 +89,11 @@ def _make_crit(da):
crd,
np.concatenate(
[
- da[crd].values
- if crd in da.coords
- else [np.NaN] * da.criteria.size
+ (
+ da[crd].values
+ if crd in da.coords
+ else [np.NaN] * da.criteria.size
+ )
for da in stacked.values()
],
),
@@ -421,9 +424,7 @@ def _calc_rsq(z, method, make_graph, n_sim, random_state, sample_weights):
random_state=random_state,
)
kmeans = kmeans.fit(z, sample_weight=sample_weights)
- sumd[
- nclust
- ] = (
+ sumd[nclust] = (
kmeans.inertia_
) # sum of the squared distance between each simulation and the nearest cluster centroid
diff --git a/xclim/ensembles/_robustness.py b/xclim/ensembles/_robustness.py
index 3502defba..b515f3351 100644
--- a/xclim/ensembles/_robustness.py
+++ b/xclim/ensembles/_robustness.py
@@ -6,6 +6,7 @@
This submodule is inspired by and tries to follow the guidelines of the IPCC, more specifically
the 12th chapter of the Working Group 1's contribution to the AR5 :cite:p:`collins_long-term_2013` (see box 12.1).
"""
+
from __future__ import annotations
import warnings
diff --git a/xclim/indicators/__init__.py b/xclim/indicators/__init__.py
index 5612554b9..93e04f8dd 100644
--- a/xclim/indicators/__init__.py
+++ b/xclim/indicators/__init__.py
@@ -1,4 +1,5 @@
"""Indicators module."""
+
# The actual code for importing virtual modules is in the top-level __init__.
# This is for import reasons: we need to make sure all normal indicators are created before.
from __future__ import annotations
diff --git a/xclim/indicators/atmos/__init__.py b/xclim/indicators/atmos/__init__.py
index e02cf28cd..07498d6db 100644
--- a/xclim/indicators/atmos/__init__.py
+++ b/xclim/indicators/atmos/__init__.py
@@ -10,6 +10,7 @@
for each indicator.
"""
+
from __future__ import annotations
from ._conversion import *
diff --git a/xclim/indicators/atmos/_conversion.py b/xclim/indicators/atmos/_conversion.py
index f1ccab51d..f2cd58d6a 100644
--- a/xclim/indicators/atmos/_conversion.py
+++ b/xclim/indicators/atmos/_conversion.py
@@ -1,4 +1,5 @@
"""Atmospheric conversion definitions."""
+
from __future__ import annotations
from inspect import _empty # noqa
diff --git a/xclim/indicators/atmos/_precip.py b/xclim/indicators/atmos/_precip.py
index efb0b73ae..fa24004fa 100644
--- a/xclim/indicators/atmos/_precip.py
+++ b/xclim/indicators/atmos/_precip.py
@@ -1,4 +1,5 @@
"""Precipitation indicator definitions."""
+
from __future__ import annotations
from inspect import _empty # noqa
diff --git a/xclim/indicators/atmos/_synoptic.py b/xclim/indicators/atmos/_synoptic.py
index ae95c0d2c..7e079bdfd 100644
--- a/xclim/indicators/atmos/_synoptic.py
+++ b/xclim/indicators/atmos/_synoptic.py
@@ -1,4 +1,5 @@
"""Synoptic indicator definitions."""
+
from __future__ import annotations
from xclim import indices
diff --git a/xclim/indicators/atmos/_temperature.py b/xclim/indicators/atmos/_temperature.py
index b1828cbc9..dfcddf5ac 100644
--- a/xclim/indicators/atmos/_temperature.py
+++ b/xclim/indicators/atmos/_temperature.py
@@ -1,4 +1,5 @@
"""Temperature indicator definitions."""
+
from __future__ import annotations
from xclim import indices
diff --git a/xclim/indicators/generic/__init__.py b/xclim/indicators/generic/__init__.py
index 9a73f6e55..c942f9dfd 100644
--- a/xclim/indicators/generic/__init__.py
+++ b/xclim/indicators/generic/__init__.py
@@ -2,6 +2,7 @@
Generic Indicators
==================
"""
+
from __future__ import annotations
from ._stats import *
diff --git a/xclim/indicators/land/__init__.py b/xclim/indicators/land/__init__.py
index 67fbe21d6..c24018ba6 100644
--- a/xclim/indicators/land/__init__.py
+++ b/xclim/indicators/land/__init__.py
@@ -2,6 +2,7 @@
Land Indicators
===============
"""
+
from __future__ import annotations
from ._snow import *
diff --git a/xclim/indicators/land/_streamflow.py b/xclim/indicators/land/_streamflow.py
index 9459d9995..4823da005 100644
--- a/xclim/indicators/land/_streamflow.py
+++ b/xclim/indicators/land/_streamflow.py
@@ -1,4 +1,5 @@
"""Streamflow indicator definitions."""
+
from __future__ import annotations
from xclim.core.cfchecks import check_valid
diff --git a/xclim/indicators/seaIce/__init__.py b/xclim/indicators/seaIce/__init__.py
index 2f2066680..45a78b5dd 100644
--- a/xclim/indicators/seaIce/__init__.py
+++ b/xclim/indicators/seaIce/__init__.py
@@ -2,6 +2,7 @@
Ice-related indicators
======================
"""
+
from __future__ import annotations
from ._seaice import *
diff --git a/xclim/indicators/seaIce/_seaice.py b/xclim/indicators/seaIce/_seaice.py
index ec9f52b4e..d791e788d 100644
--- a/xclim/indicators/seaIce/_seaice.py
+++ b/xclim/indicators/seaIce/_seaice.py
@@ -2,6 +2,7 @@
Sea ice indicators
------------------
"""
+
from __future__ import annotations
from xclim import indices
diff --git a/xclim/indices/__init__.py b/xclim/indices/__init__.py
index 7d587f2f8..9689d5208 100644
--- a/xclim/indices/__init__.py
+++ b/xclim/indices/__init__.py
@@ -1,4 +1,5 @@
"""Indices module."""
+
from __future__ import annotations
from ._agro import *
diff --git a/xclim/indices/fire/_cffwis.py b/xclim/indices/fire/_cffwis.py
index 531916fe5..31838d680 100644
--- a/xclim/indices/fire/_cffwis.py
+++ b/xclim/indices/fire/_cffwis.py
@@ -123,6 +123,7 @@
... dmc_dry_factor=2,
... )
"""
+
# This file is structured in the following way:
# Section 1: individual codes, numba-accelerated and vectorized functions.
# Section 2: Larger computing functions (the FWI iterator and the fire_season iterator)
@@ -1162,8 +1163,9 @@ def overwintering_drought_code(
last_dc: xr.DataArray,
winter_pr: xr.DataArray,
carry_over_fraction: xr.DataArray | float = default_params["carry_over_fraction"],
- wetting_efficiency_fraction: xr.DataArray
- | float = default_params["wetting_efficiency_fraction"],
+ wetting_efficiency_fraction: xr.DataArray | float = default_params[
+ "wetting_efficiency_fraction"
+ ],
min_dc: xr.DataArray | float = default_params["dc_start"],
) -> xr.DataArray:
"""Compute season-starting drought code based on previous season's last drought code and total winter precipitation.
diff --git a/xclim/indices/generic.py b/xclim/indices/generic.py
index f552eb5b3..88a7c9d15 100644
--- a/xclim/indices/generic.py
+++ b/xclim/indices/generic.py
@@ -4,6 +4,7 @@
Helper functions for common generic actions done in the computation of indices.
"""
+
from __future__ import annotations
import warnings
diff --git a/xclim/indices/helpers.py b/xclim/indices/helpers.py
index 44e24cb17..64d5716f5 100644
--- a/xclim/indices/helpers.py
+++ b/xclim/indices/helpers.py
@@ -4,6 +4,7 @@
Functions that encapsulate some geophysical logic but could be shared by many indices.
"""
+
from __future__ import annotations
from inspect import stack
diff --git a/xclim/indices/run_length.py b/xclim/indices/run_length.py
index 855f4e4c3..059b8cb6d 100644
--- a/xclim/indices/run_length.py
+++ b/xclim/indices/run_length.py
@@ -4,6 +4,7 @@
Computation of statistics on runs of True values in boolean arrays.
"""
+
from __future__ import annotations
from datetime import datetime
diff --git a/xclim/indices/stats.py b/xclim/indices/stats.py
index c8a9396b4..f89bcb5ca 100644
--- a/xclim/indices/stats.py
+++ b/xclim/indices/stats.py
@@ -1,4 +1,5 @@
"""Statistic-related functions. See the `frequency_analysis` notebook for examples."""
+
from __future__ import annotations
import warnings
diff --git a/xclim/sdba/__init__.py b/xclim/sdba/__init__.py
index 5823a9b08..911d89c42 100644
--- a/xclim/sdba/__init__.py
+++ b/xclim/sdba/__init__.py
@@ -3,6 +3,7 @@
SDBA submodule
==============
"""
+
from __future__ import annotations
from . import adjustment, detrending, measures, processing, properties, utils
diff --git a/xclim/sdba/_adjustment.py b/xclim/sdba/_adjustment.py
index 5a651a7ea..37c37be44 100644
--- a/xclim/sdba/_adjustment.py
+++ b/xclim/sdba/_adjustment.py
@@ -4,6 +4,7 @@
This file defines the different steps, to be wrapped into the Adjustment objects.
"""
+
from __future__ import annotations
import numpy as np
diff --git a/xclim/sdba/_processing.py b/xclim/sdba/_processing.py
index eb7a862b6..cceef5461 100644
--- a/xclim/sdba/_processing.py
+++ b/xclim/sdba/_processing.py
@@ -5,6 +5,7 @@
Here are defined the functions wrapped by map_blocks or map_groups.
The user-facing, metadata-handling functions should be defined in processing.py.
"""
+
from __future__ import annotations
from typing import Sequence
diff --git a/xclim/sdba/base.py b/xclim/sdba/base.py
index f85ff7974..9d54c5149 100644
--- a/xclim/sdba/base.py
+++ b/xclim/sdba/base.py
@@ -2,6 +2,7 @@
Base Classes and Developer Tools
================================
"""
+
from __future__ import annotations
from inspect import _empty, signature # noqa
diff --git a/xclim/sdba/detrending.py b/xclim/sdba/detrending.py
index 72b6c7362..85d74b4a1 100644
--- a/xclim/sdba/detrending.py
+++ b/xclim/sdba/detrending.py
@@ -2,6 +2,7 @@
Detrending Objects Utilities
============================
"""
+
from __future__ import annotations
import xarray as xr
diff --git a/xclim/sdba/loess.py b/xclim/sdba/loess.py
index 3c39bc7de..d98c4ff68 100644
--- a/xclim/sdba/loess.py
+++ b/xclim/sdba/loess.py
@@ -2,6 +2,7 @@
LOESS Smoothing Submodule
=========================
"""
+
from __future__ import annotations
from typing import Callable
diff --git a/xclim/sdba/measures.py b/xclim/sdba/measures.py
index b1fa8a5d0..972ed1c16 100644
--- a/xclim/sdba/measures.py
+++ b/xclim/sdba/measures.py
@@ -6,6 +6,7 @@
`VALUE `_ project.
"""
+
from __future__ import annotations
from typing import Sequence
diff --git a/xclim/sdba/utils.py b/xclim/sdba/utils.py
index f3d523967..0b6b29067 100644
--- a/xclim/sdba/utils.py
+++ b/xclim/sdba/utils.py
@@ -2,6 +2,7 @@
Statistical Downscaling and Bias Adjustment Utilities
=====================================================
"""
+
from __future__ import annotations
import itertools
diff --git a/xclim/testing/__init__.py b/xclim/testing/__init__.py
index da3b0411d..c6f0f7748 100644
--- a/xclim/testing/__init__.py
+++ b/xclim/testing/__init__.py
@@ -1,4 +1,5 @@
"""Helpers for testing xclim."""
+
from __future__ import annotations
from . import diagnostics, helpers
diff --git a/xclim/testing/helpers.py b/xclim/testing/helpers.py
index 93397e662..abce4f21d 100644
--- a/xclim/testing/helpers.py
+++ b/xclim/testing/helpers.py
@@ -1,4 +1,5 @@
"""Module for loading testing data."""
+
from __future__ import annotations
import os
diff --git a/xclim/testing/sdba_utils.py b/xclim/testing/sdba_utils.py
index a8bd0f275..e31306899 100644
--- a/xclim/testing/sdba_utils.py
+++ b/xclim/testing/sdba_utils.py
@@ -2,6 +2,7 @@
SDBA Testing Utilities Module
=============================
"""
+
from __future__ import annotations
import collections
diff --git a/xclim/testing/utils.py b/xclim/testing/utils.py
index c4bb93211..5f551cee0 100644
--- a/xclim/testing/utils.py
+++ b/xclim/testing/utils.py
@@ -2,6 +2,7 @@
Testing and Tutorial Utilities' Module
======================================
"""
+
# Some of this code was copied and adapted from xarray
from __future__ import annotations
From 50332ec1ea6dac272a401eb907c3d1df5d480b10 Mon Sep 17 00:00:00 2001
From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com>
Date: Fri, 26 Jan 2024 11:54:50 -0500
Subject: [PATCH 6/8] update black pin
---
.pre-commit-config.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 992dee29f..1a76759fe 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -73,7 +73,7 @@ repos:
rev: v0.3.9
hooks:
- id: blackdoc
- additional_dependencies: [ 'black==23.12.1' ]
+ additional_dependencies: [ 'black==24.1.0' ]
exclude: '(xclim/indices/__init__.py|docs/installation.rst)'
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.1
From 17490d3715b13af4925ffd35967f3b7b8889dfd0 Mon Sep 17 00:00:00 2001
From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com>
Date: Fri, 26 Jan 2024 11:57:21 -0500
Subject: [PATCH 7/8] run formatters
---
xclim/core/units.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/xclim/core/units.py b/xclim/core/units.py
index a23b385af..92705e009 100644
--- a/xclim/core/units.py
+++ b/xclim/core/units.py
@@ -1092,8 +1092,7 @@ def declare_relative_units(**units_by_name) -> Callable:
.. code-block:: python
@declare_relative_units(thresh="", thresh2=" / [time]")
- def func(da, thresh, thresh2):
- ...
+ def func(da, thresh, thresh2): ...
The decorator will check that `thresh` has units compatible with those of da
and that `thresh2` has units compatible with the time derivative of da.
@@ -1200,8 +1199,7 @@ def declare_units(**units_by_name) -> Callable:
.. code-block:: python
@declare_units(tas="[temperature]")
- def func(tas):
- ...
+ def func(tas): ...
The decorator will check that `tas` has units of temperature (C, K, F).
From 42b349f43e326d2171d197c6960ce773a6557f0d Mon Sep 17 00:00:00 2001
From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com>
Date: Fri, 26 Jan 2024 11:58:18 -0500
Subject: [PATCH 8/8] update CHANGES.rst
---
CHANGES.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 85792c664..c561fc087 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -25,7 +25,7 @@ Breaking changes
* `xclim`'s units registry and units formatting are now extended from `cf-xarray`. The exponent sign "^" is now never added in the ``units`` attribute. For example, square meters are given as "m2" instead of "m^2" by xclim, both are still accepted as input. (:issue:`1010`, :pull:`1590`).
* `yamale` is now listed as a core dependency (was previously listed in the `dev` installation recipe). (:issue:`1595`, :pull:`1596`).
* Due to a licensing limitation, the calculation of empirical orthogonal function based on `eofs` (``xclim.sdba.properties.first_eof``) has been removed from `xclim`. (:issue:`1620`, :pull:`1621`).
-* `black` formatting style has been updated to the 2024 stable conventions. `isort` has been added to the `dev` installation recipe.
+* `black` formatting style has been updated to the 2024 stable conventions. `isort` has been added to the `dev` installation recipe. (:pull:`1626`).
Bug fixes
^^^^^^^^^
@@ -48,7 +48,7 @@ Internal changes
* A new GitHub Workflow (``workflow-warning.yml``) has been added to warn maintainers when a forked repository has been used to open a Pull Request that modifies GitHub Workflows.
* `pylint` has been configured to provide some overhead checks of the `xclim` codebase as well as run as part of `xclim`'s `pre-commit` hooks.
* Some small adjustments to code organization to address `pylint` errors.
-* `dev` formatting tools (`black`, `blackdoc`, `isort`) are now pinned to their `pre-commit` hook version equivalents in both `pyproject.toml` and `tox.ini`.
+* `dev` formatting tools (`black`, `blackdoc`, `isort`) are now pinned to their `pre-commit` hook version equivalents in both `pyproject.toml` and `tox.ini`. (:pull:`1626`).
v0.47.0 (2023-12-01)
--------------------