diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 15400882..278de930 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: # Run ruff to lint and format - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.8.6 + rev: v0.9.4 hooks: # Run the linter. - id: ruff @@ -25,7 +25,7 @@ repos: # Find common spelling mistakes in comments and docstrings - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.1 hooks: - id: codespell args: ['--ignore-regex="(\b[A-Z]+\b)"'] # Ignore capital case words, e.g. country codes diff --git a/atlite/convert.py b/atlite/convert.py index 4b725eab..96a2974e 100644 --- a/atlite/convert.py +++ b/atlite/convert.py @@ -148,7 +148,7 @@ def convert_and_aggregate( if matrix is not None: if shapes is not None: raise ValueError( - "Passing matrix and shapes is ambiguous. Pass " "only one of them." + "Passing matrix and shapes is ambiguous. Pass only one of them." ) if isinstance(matrix, xr.DataArray): diff --git a/atlite/cutout.py b/atlite/cutout.py index cd10c755..5dceec1f 100644 --- a/atlite/cutout.py +++ b/atlite/cutout.py @@ -154,7 +154,7 @@ def __init__(self, path, **cutoutparams): data.attrs.update(storable_chunks) if cutoutparams: warn( - f'Arguments {", ".join(cutoutparams)} are ignored, since ' + f"Arguments {', '.join(cutoutparams)} are ignored, since " "cutout is already built." ) elif "data" in cutoutparams: diff --git a/atlite/datasets/era5.py b/atlite/datasets/era5.py index d1e5224f..2b5d547c 100644 --- a/atlite/datasets/era5.py +++ b/atlite/datasets/era5.py @@ -341,9 +341,9 @@ def retrieve_data(product, chunks=None, tmpdir=None, lock=None, **updates): request = {"product_type": "reanalysis", "format": "netcdf"} request.update(updates) - assert {"year", "month", "variable"}.issubset( - request - ), "Need to specify at least 'variable', 'year' and 'month'" + assert {"year", "month", "variable"}.issubset(request), ( + "Need to specify at least 'variable', 'year' and 'month'" + ) client = cdsapi.Client( info_callback=logger.debug, debug=logging.DEBUG >= logging.root.level diff --git a/atlite/gis.py b/atlite/gis.py index d41d8ac5..69e11678 100644 --- a/atlite/gis.py +++ b/atlite/gis.py @@ -481,9 +481,7 @@ def open_files(self): if d["crs"]: raster._crs = CRS(d["crs"]) else: - raise ValueError( - f"CRS of {raster} is invalid, please " "provide it." - ) + raise ValueError(f"CRS of {raster} is invalid, please provide it.") d["raster"] = raster for d in self.geometries: @@ -733,9 +731,9 @@ def compute_availabilitymatrix( _ = shape_availability_reprojected(shapes.loc[[i]], *args)[0] availability.append(_) else: - assert ( - excluder.all_closed - ), "For parallelization all raster files in excluder must be closed" + assert excluder.all_closed, ( + "For parallelization all raster files in excluder must be closed" + ) kwargs = { "initializer": _init_process, "initargs": (shapes, *args), diff --git a/atlite/hydro.py b/atlite/hydro.py index 8cacb6df..df08aacc 100644 --- a/atlite/hydro.py +++ b/atlite/hydro.py @@ -51,10 +51,10 @@ def determine_basins(plants, hydrobasins, show_progress=False): missing_columns = pd.Index( ["HYBAS_ID", "DIST_MAIN", "NEXT_DOWN", "geometry"] ).difference(hydrobasins.columns) - assert ( - missing_columns.empty - ), "Couldn't find the column(s) {} in the hydrobasins dataset.".format( - ", ".join(missing_columns) + assert missing_columns.empty, ( + "Couldn't find the column(s) {} in the hydrobasins dataset.".format( + ", ".join(missing_columns) + ) ) hydrobasins = hydrobasins.set_index("HYBAS_ID") diff --git a/atlite/pv/irradiation.py b/atlite/pv/irradiation.py index 967bf789..8275d58f 100644 --- a/atlite/pv/irradiation.py +++ b/atlite/pv/irradiation.py @@ -64,9 +64,7 @@ def DiffuseHorizontalIrrad(ds, solar_position, clearsky_model, influx): * fmax(0.1, 0.426 * k - 0.256 * sinaltitude + 0.00349 * T + 0.0734 * rh) ) else: - raise KeyError( - "`clearsky model` must be chosen from 'simple' and " "'enhanced'" - ) + raise KeyError("`clearsky model` must be chosen from 'simple' and 'enhanced'") # Set diffuse fraction to one when the sun isn't up # fraction = fraction.where(sinaltitude >= sin(radians(threshold))).fillna(1.0) diff --git a/atlite/wind.py b/atlite/wind.py index b04efc02..92dd1f19 100644 --- a/atlite/wind.py +++ b/atlite/wind.py @@ -112,8 +112,7 @@ def extrapolate_wind_speed( method_desc = "power method with wind shear exponent" else: raise ValueError( - f"Interpolation method must be 'logarithmic' or 'power', " - f" but is: {method}" + f"Interpolation method must be 'logarithmic' or 'power', but is: {method}" ) wnd_spd.attrs.update( diff --git a/doc/chart.py b/doc/chart.py index 9df199b4..e03a0e0b 100755 --- a/doc/chart.py +++ b/doc/chart.py @@ -29,7 +29,7 @@ f"Solar PV power generation {linebreak}for a given panel type", "Solar thermal collector heat output", "Hydroelectric inflow (simplified)", - f"Heating demand {linebreak}" "(based on the degree-day approximation)", + f"Heating demand {linebreak}(based on the degree-day approximation)", ] climatestr = "\n" + "\n\n".join([" ◦ " + s for s in climatedata]) + "\n" diff --git a/examples/working-with-csp.ipynb b/examples/working-with-csp.ipynb index 78e88331..009a6331 100644 --- a/examples/working-with-csp.ipynb +++ b/examples/working-with-csp.ipynb @@ -156,7 +156,7 @@ " vmin=0,\n", " vmax=1.0,\n", " )\n", - " axes[i].set_title(f'{name} (technology: {config[\"technology\"]})')\n", + " axes[i].set_title(f\"{name} (technology: {config['technology']})\")\n", " axes[i].set_xlim(0, 360)\n", " axes[i].set_ylim(0, 90)" ] diff --git a/test/test_preparation_and_conversion.py b/test/test_preparation_and_conversion.py index 01127548..34133445 100644 --- a/test/test_preparation_and_conversion.py +++ b/test/test_preparation_and_conversion.py @@ -408,7 +408,7 @@ def test_all_non_na_era5_coarse(cutout_era5_coarse): @staticmethod @pytest.mark.skipif( os.name == "nt", - reason="This test breaks on windows machine on CI" " due to unknown reasons.", + reason="This test breaks on windows machine on CI due to unknown reasons.", ) def test_all_non_na_era5_weird_resolution(cutout_era5_weird_resolution): """ @@ -439,7 +439,7 @@ def test_dx_dy_preservation_era5_coarse(cutout_era5_coarse): @staticmethod @pytest.mark.skipif( os.name == "nt", - reason="This test breaks on windows machine on CI" " due to unknown reasons.", + reason="This test breaks on windows machine on CI due to unknown reasons.", ) def test_dx_dy_preservation_era5_weird_resolution(cutout_era5_weird_resolution): """