Skip to content

Commit 75f1064

Browse files
authored
Update pre-commit hooks to latest versions (#658)
1 parent e43d533 commit 75f1064

Some content is hidden

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

49 files changed

+170
-209
lines changed

.pre-commit-config.yaml

+13-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ci:
33
autoupdate_schedule: quarterly
44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.3.0
6+
rev: v5.0.0
77
hooks:
88
- id: check-yaml
99
- id: end-of-file-fixer
@@ -13,7 +13,7 @@ repos:
1313

1414
# Fix common spelling mistakes
1515
- repo: https://github.com/codespell-project/codespell
16-
rev: v2.2.1
16+
rev: v2.3.0
1717
hooks:
1818
- id: codespell
1919
args: [
@@ -32,30 +32,30 @@ repos:
3232

3333
# Format the code aggressively using black
3434
- repo: https://github.com/psf/black
35-
rev: 22.10.0
35+
rev: 24.10.0
3636
hooks:
3737
- id: black
3838
args: [--line-length=120]
3939

4040
# Lint the code using flake8
4141
- repo: https://github.com/pycqa/flake8
42-
rev: 3.9.2
42+
rev: 7.1.1
4343
hooks:
4444
- id: flake8
4545
# More than one argument in the second list, so need to pass arguments as below (and -- to finish)
4646
args: [
4747
'--max-line-length', '120', # we can write dicts however we want
48-
'--extend-ignore', 'E203,C408', # flake8 disagrees with black, so this should be ignored.
48+
'--extend-ignore', 'E203,C408,B028', # flake8 disagrees with black, so this should be ignored.
4949
'--'
5050
]
5151
additional_dependencies:
52-
- flake8-comprehensions==3.1.0
53-
- flake8-bugbear==21.3.2
52+
- flake8-comprehensions
53+
- flake8-bugbear
5454
files: ^(xdem|tests)
5555

5656
# Lint the code using mypy
5757
- repo: https://github.com/pre-commit/mirrors-mypy
58-
rev: v0.982
58+
rev: v1.13.0
5959
hooks:
6060
- id: mypy
6161
args: [
@@ -72,27 +72,27 @@ repos:
7272
--disable-error-code=no-any-return
7373

7474
]
75-
additional_dependencies: [tokenize-rt==3.2.0, numpy==1.22]
75+
additional_dependencies: [tokenize-rt==3.2.0, numpy==1.26]
7676
files: ^(xdem|tests|doc/code)
7777

7878

7979
# Sort imports using isort
8080
- repo: https://github.com/PyCQA/isort
81-
rev: 5.12.0
81+
rev: 5.13.2
8282
hooks:
8383
- id: isort
8484
args: ["--profile", "black"]
8585

8686
# Automatically upgrade syntax to a minimum version
8787
- repo: https://github.com/asottile/pyupgrade
88-
rev: v3.1.0
88+
rev: v3.19.0
8989
hooks:
9090
- id: pyupgrade
9191
args: [--py37-plus]
9292

9393
# Various formattings
9494
- repo: https://github.com/pre-commit/pygrep-hooks
95-
rev: v1.9.0
95+
rev: v1.10.0
9696
hooks:
9797
# Single backticks should apparently not be used
9898
- id: rst-backticks
@@ -111,7 +111,7 @@ repos:
111111

112112
# Add custom regex lints (see .relint.yml)
113113
- repo: https://github.com/codingjoe/relint
114-
rev: 2.0.0
114+
rev: 3.3.1
115115
hooks:
116116
- id: relint
117117
- repo: local

doc/source/background.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ And finally:
130130
- **Reproducibility:** all code should be version-controlled and release-based, to ensure consistency of dependent
131131
packages and works;
132132

133-
- **Open-source:** all code should be accessible and re-usable to anyone in the community, for transparency and open governance.
133+
- **Open-source:** all code should be accessible and reusable to anyone in the community, for transparency and open governance.

doc/source/code/comparison_plot_local_hypsometric_interpolation.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Plot an example of local hypsometric interpolation at Scott Turnerbreen, Svalbard."""
2+
23
import geoutils as gu
34
import matplotlib.pyplot as plt
45
import numpy as np

doc/source/code/comparison_plot_regional_hypsometric_interpolation.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Plot an example of regional hypsometric interpolation in central Svalbard."""
2+
23
import geoutils as gu
34
import matplotlib.pyplot as plt
45
import numpy as np

doc/source/code/comparison_plot_spatial_interpolation.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Plot an example of spatial interpolation of randomly generated errors."""
2+
23
import geoutils as gu
34
import matplotlib.pyplot as plt
45
import numpy as np

doc/source/code/intricacies_datatypes.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Plot example of elevation data types for guide page."""
2+
23
import matplotlib
34
import matplotlib.pyplot as plt
45
import numpy as np

doc/source/code/robust_mean_std.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Plot example of NMAD/median as robust estimators for guide page."""
2+
23
import matplotlib.pyplot as plt
34
import numpy as np
45

doc/source/code/robust_vario.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Plot example of Dowd variogram as robust estimator for guide page."""
2+
23
import matplotlib.pyplot as plt
34
import numpy as np
45
from skgstat import OrdinaryKriging, Variogram

doc/source/code/spatialstats_heterosc_slope.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Code example for spatial statistics"""
2+
23
import geoutils as gu
34
import numpy as np
45

doc/source/code/spatialstats_standardizing.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Documentation plot illustrating standardization of a distribution"""
2+
23
import matplotlib.pyplot as plt
34
import numpy as np
45

doc/source/code/spatialstats_stationarity_assumption.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Documentation plot illustrating stationarity of mean and variance"""
2+
23
import matplotlib.pyplot as plt
34
import numpy as np
45

doc/source/code/spatialstats_variogram_covariance.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Documentation plot illustrating the link between variogram and covariance"""
2+
23
import matplotlib.pyplot as plt
34
import numpy as np
45
from skgstat.models import exponential

doc/source/sphinxext.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Functions for documentation configuration only, importable by sphinx"""
2+
3+
24
# To reset resolution setting for each sphinx-gallery example
35
def reset_mpl(gallery_conf, fname):
46
# To get a good resolution for displayed figures

examples/advanced/plot_blockwise_coreg.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
5. Warp the DEM to apply the X/Y/Z shifts.
1717
1818
"""
19+
1920
import geoutils as gu
2021

2122
# sphinx_gallery_thumbnail_number = 2

examples/advanced/plot_deramp.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
See also the :ref:`deramp` section in feature pages.
99
"""
10+
1011
import geoutils as gu
1112
import numpy as np
1213

examples/advanced/plot_heterosc_estimation_modelling.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
2020
**Reference:** `Hugonnet et al. (2022) <https://doi.org/10.1109/jstars.2022.3188922>`_.
2121
"""
22+
2223
import geoutils as gu
2324

2425
# sphinx_gallery_thumbnail_number = 8

examples/advanced/plot_norm_regional_hypso.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
2828
The consequence is a much more accurate interpolation approach that can be used in a multitude of glacierized settings.
2929
"""
30+
3031
import geoutils as gu
3132

3233
# sphinx_gallery_thumbnail_number = 2

examples/advanced/plot_slope_methods.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
1010
**References:** `Horn (1981) <https://ieeexplore.ieee.org/document/1456186>`_, `Zevenbergen and Thorne (1987) <http://dx.doi.org/10.1002/esp.3290120107>`_.
1111
"""
12+
1213
import matplotlib.pyplot as plt
1314
import numpy as np
1415

examples/advanced/plot_standardization.py

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
1414
**Reference**: `Hugonnet et al. (2022) <https://doi.org/10.1109/jstars.2022.3188922>`_.
1515
"""
16+
1617
import geoutils as gu
1718

1819
# sphinx_gallery_thumbnail_number = 4

examples/advanced/plot_variogram_estimation_modelling.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
2121
**References:** `Rolstad et al. (2009) <http://dx.doi.org/10.3189/002214309789470950>`_, `Hugonnet et al. (2022) <https://doi.org/10.1109/jstars.2022.3188922>`_.
2222
"""
23+
2324
import geoutils as gu
2425

2526
# sphinx_gallery_thumbnail_number = 6

examples/basic/plot_dem_subtraction.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Before DEMs can be compared, they need to be reprojected to the same grid and have the same 3D CRSs. The :func:`~xdem.DEM.reproject` and :func:`~xdem.DEM.to_vcrs` methods are used for this.
1111
1212
"""
13+
1314
import geoutils as gu
1415

1516
import xdem

examples/basic/plot_icp_coregistration.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1111
**References**: `Besl and McKay (1992) <https://doi.org/10.1117/12.57955>`_.
1212
"""
13+
1314
# sphinx_gallery_thumbnail_number = 2
1415
import matplotlib.pyplot as plt
1516
import numpy as np

examples/basic/plot_infer_heterosc.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
1010
**Reference:** `Hugonnet et al. (2022) <https://doi.org/10.1109/jstars.2022.3188922>`_.
1111
"""
12+
1213
import geoutils as gu
1314

1415
# sphinx_gallery_thumbnail_number = 1

examples/basic/plot_infer_spatial_correlation.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
99
**References:** `Rolstad et al. (2009) <http://dx.doi.org/10.3189/002214309789470950>`_, `Hugonnet et al. (2022) <https://doi.org/10.1109/jstars.2022.3188922>`_.
1010
"""
11+
1112
import geoutils as gu
1213

1314
# sphinx_gallery_thumbnail_number = 1

examples/basic/plot_nuth_kaab.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1111
**Reference:** `Nuth and Kääb (2011) <https:https://doi.org/10.5194/tc-5-271-2011>`_.
1212
"""
13+
1314
import geoutils as gu
1415
import numpy as np
1516

examples/basic/plot_spatial_error_propagation.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
1010
**References:** `Rolstad et al. (2009) <http://dx.doi.org/10.3189/002214309789470950>`_, `Hugonnet et al. (2022) <https://doi.org/10.1109/jstars.2022.3188922>`_.
1111
"""
12+
1213
import geoutils as gu
1314
import matplotlib.pyplot as plt
1415

examples/basic/plot_terrain_attributes.py

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
`Riley et al. (1999) <http://download.osgeo.org/qgis/doc/reference-docs/Terrain_Ruggedness_Index.pdf>`_ (terrain
1313
ruggedness index), `Jenness (2004) <https://doi.org/10.2193/0091-7648(2004)032%5B0829:CLSAFD%5D2.0.CO;2>`_ (rugosity).
1414
"""
15+
1516
# sphinx_gallery_thumbnail_number = 1
1617
import matplotlib.pyplot as plt
1718

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This file now only serves for backward-compatibility for routines explicitly calling python setup.py"""
2+
23
from setuptools import setup
34

45
setup()

tests/test_coreg/test_affine.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Functions to test the affine coregistrations."""
2+
23
from __future__ import annotations
34

45
import warnings
@@ -409,7 +410,7 @@ def test_coreg_rigid__synthetic(self, fit_args, shifts_rotations, coreg_method)
409410
matrix[:3, 3] = shifts
410411

411412
# Pass a centroid
412-
centroid = [ref.bounds.left, ref.bounds.bottom, np.nanmean(ref)]
413+
centroid = (ref.bounds.left, ref.bounds.bottom, np.nanmean(ref))
413414
ref_shifted_rotated = coreg.apply_matrix(ref, matrix=matrix, centroid=centroid)
414415

415416
# Convert to point cloud if input was point cloud

tests/test_coreg/test_base.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def assert_coreg_meta_equal(input1: Any, input2: Any) -> bool:
4949
"""Short test function to check equality of coreg dictionary values."""
5050

5151
# Different equality check based on input: number, callable, array, dataframe
52-
if type(input1) != type(input2):
52+
if not isinstance(input1, type(input2)):
5353
return False
5454
elif isinstance(input1, (str, float, int, np.floating, np.integer, tuple, list)) or callable(input1):
5555
return input1 == input2
@@ -466,12 +466,16 @@ def test_fit_and_apply__pipeline(self) -> None:
466466
assert aligned_and.raster_equal(aligned_then, warn_failure_reason=True)
467467
assert list(coreg_fit_and_apply.pipeline[0].meta.keys()) == list(coreg_fit_then_apply.pipeline[0].meta.keys())
468468
assert all(
469-
assert_coreg_meta_equal(coreg_fit_and_apply.pipeline[0].meta[k], coreg_fit_then_apply.pipeline[0].meta[k])
469+
assert_coreg_meta_equal(
470+
coreg_fit_and_apply.pipeline[0].meta[k], coreg_fit_then_apply.pipeline[0].meta[k] # type: ignore
471+
)
470472
for k in coreg_fit_and_apply.pipeline[0].meta.keys()
471473
)
472474
assert list(coreg_fit_and_apply.pipeline[1].meta.keys()) == list(coreg_fit_then_apply.pipeline[1].meta.keys())
473475
assert all(
474-
assert_coreg_meta_equal(coreg_fit_and_apply.pipeline[1].meta[k], coreg_fit_then_apply.pipeline[1].meta[k])
476+
assert_coreg_meta_equal(
477+
coreg_fit_and_apply.pipeline[1].meta[k], coreg_fit_then_apply.pipeline[1].meta[k] # type: ignore
478+
)
475479
for k in coreg_fit_and_apply.pipeline[1].meta.keys()
476480
)
477481

@@ -702,9 +706,7 @@ def test_pipeline_combinations__biasvar(
702706
"""Test pipelines with all combinations of coregistration subclasses with bias variables"""
703707

704708
# Create a pipeline from one affine and one biascorr methods
705-
pipeline = coreg.CoregPipeline([coreg1(), coreg.BiasCorr(**coreg2_init_kwargs)])
706-
print(pipeline.pipeline[0].meta["inputs"]["random"]["subsample"])
707-
print(pipeline.pipeline[1].meta["inputs"]["random"]["subsample"])
709+
pipeline = coreg.CoregPipeline([coreg1(), coreg.BiasCorr(**coreg2_init_kwargs)]) # type: ignore
708710
bias_vars = {"slope": xdem.terrain.slope(self.ref), "aspect": xdem.terrain.aspect(self.ref)}
709711
pipeline.fit(**self.fit_params, bias_vars=bias_vars, subsample=5000, random_state=42)
710712

tests/test_coreg/test_biascorr.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests for the biascorr module (non-rigid coregistrations)."""
2+
23
from __future__ import annotations
34

45
import re

tests/test_coreg/test_workflows.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Functions to test the coregistration workflows."""
2+
23
from __future__ import annotations
34

45
import os

tests/test_dem.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" Functions to test the DEM tools."""
2+
23
from __future__ import annotations
34

45
import os

tests/test_demcollection.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Functions to test the DEM collection tools."""
2+
23
import datetime
34
import warnings
45

tests/test_doc.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Functions to test the documentation."""
2+
23
import logging
34
import os
45
import platform

tests/test_examples.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Functions to test the example data."""
2+
23
from __future__ import annotations
34

45
import geoutils as gu

tests/test_filters.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Functions to test the filtering tools."""
2+
23
from __future__ import annotations
34

45
import geoutils as gu

tests/test_fit.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Functions to test the fitting tools.
33
"""
4+
45
import platform
56
import warnings
67

tests/test_misc.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test the xdem.misc functions."""
2+
23
from __future__ import annotations
34

45
import os

0 commit comments

Comments
 (0)