diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cb8f1e5..456c5e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,6 +16,6 @@ repos: - id: check-added-large-files # Code formatting with black - repo: https://github.com/psf/black-pre-commit-mirror - rev: 25.12.0 + rev: 26.1.0 hooks: - id: black diff --git a/docs/conf.py b/docs/conf.py index b0f57ee..fdf0615 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,7 +18,6 @@ import tomllib from pathlib import Path - sys.path.insert(0, os.path.abspath("..")) diff --git a/moad_tools/midoss/geotiff_watermask.py b/moad_tools/midoss/geotiff_watermask.py index e2b5f0b..cdf16e1 100644 --- a/moad_tools/midoss/geotiff_watermask.py +++ b/moad_tools/midoss/geotiff_watermask.py @@ -20,6 +20,7 @@ a SalishSeaCast domain water mask for the AIS ship track density GeoTIFF files used to generate oil spill parameters for Monte Carlo runs of MOHID. """ + import logging import sys from pathlib import Path @@ -130,8 +131,7 @@ def write_numpy_file(watermask, numpy_file): logging.info(f"wrote Numpy boolean water mask array to: {numpy_path}") -@click.command( - help=""" +@click.command(help=""" Calculate and store a Numpy array file containing a SalishSeaCast domain water mask for the AIS ship track density GeoTIFF files used to generate oil spill parameters for Monte Carlo runs of MOHID. @@ -143,8 +143,7 @@ def write_numpy_file(watermask, numpy_file): https://ubc-moad-tools.readthedocs.io/en/latest/moad_tools.html#module-moad_tools.midoss.geotiff_watermask for more information about arguments and options. - """ -) + """) @click.version_option() @click.argument( "geotiff_file", diff --git a/moad_tools/midoss/hdf5_to_netcdf4.py b/moad_tools/midoss/hdf5_to_netcdf4.py index 554a6df..caac26c 100644 --- a/moad_tools/midoss/hdf5_to_netcdf4.py +++ b/moad_tools/midoss/hdf5_to_netcdf4.py @@ -17,6 +17,7 @@ """Functions to transform an MOHID HDF5 output file into a netCDF4 file.""" + import logging import os import shlex diff --git a/moad_tools/midoss/random_oil_spills.py b/moad_tools/midoss/random_oil_spills.py index 3a17289..a9868d3 100644 --- a/moad_tools/midoss/random_oil_spills.py +++ b/moad_tools/midoss/random_oil_spills.py @@ -19,6 +19,7 @@ """Functions and command-line tool to calculate a CSV file containing parameters of a set of random oil spills to drive Monte Carlo runs of MOHID. """ + import collections import logging import sys @@ -1589,8 +1590,7 @@ def write_csv_file(df, csv_file): logging.info(f"wrote CSV file to {csv_file}") -@click.command( - help=""" +@click.command(help=""" Calculate and store a CSV file containing parameters of a set of random oil spills to drive Monte Carlo runs of MOHID. @@ -1606,8 +1606,7 @@ def write_csv_file(df, csv_file): https://ubc-moad-tools.readthedocs.io/en/latest/moad_tools.html#processing-configuration-yaml-file for details of the contents of the config file. -""" -) +""") @click.version_option() @click.argument("n_spills", type=int) @click.argument( diff --git a/moad_tools/observations.py b/moad_tools/observations.py index 09b61a3..9b4038f 100644 --- a/moad_tools/observations.py +++ b/moad_tools/observations.py @@ -17,6 +17,7 @@ """Functions for downloading observations data from web services.""" + import logging import urllib.error diff --git a/tests/midoss/test_geotiff_watermask.py b/tests/midoss/test_geotiff_watermask.py index 7b441f1..ebd300d 100644 --- a/tests/midoss/test_geotiff_watermask.py +++ b/tests/midoss/test_geotiff_watermask.py @@ -17,6 +17,7 @@ """Unit tests for geotiff_watermask module.""" + import shlex import sys diff --git a/tests/midoss/test_hdf5_to_netcdf4.py b/tests/midoss/test_hdf5_to_netcdf4.py index 51f2271..9ed656d 100644 --- a/tests/midoss/test_hdf5_to_netcdf4.py +++ b/tests/midoss/test_hdf5_to_netcdf4.py @@ -17,6 +17,7 @@ """Unit tests for hdf5_to_netcdf4 module.""" + import shlex import sys diff --git a/tests/midoss/test_random_oil_spills.py b/tests/midoss/test_random_oil_spills.py index 0a58bbe..163291a 100644 --- a/tests/midoss/test_random_oil_spills.py +++ b/tests/midoss/test_random_oil_spills.py @@ -17,6 +17,7 @@ """Unit tests for random_oil_spills module.""" + import logging import shlex import sys @@ -57,9 +58,7 @@ def config_file(tmp_path): geotiff_watermask = geotiffs_dir / "geotiff-watermask.npy" ssc_mesh = test_data / "mesh_mask201702.nc" config_file = tmp_path / "random_oil_spills.yaml" - config_file.write_text( - textwrap.dedent( - f"""\ + config_file.write_text(textwrap.dedent(f"""\ start date: 2015-01-01 end date: 2018-12-31 @@ -81,9 +80,7 @@ def config_file(tmp_path): - other oil attribution: {test_data}/oil_attribution.yaml - """ - ) - ) + """)) return str(config_file) @@ -805,9 +802,7 @@ def test_get_oil_type_atb_tanker_cargo_spill( data_dir = tmp_path / "marine_transport_data" data_dir.mkdir() cargo_info_file = data_dir / "yaml_file" - cargo_info_file.write_text( - textwrap.dedent( - """\ + cargo_info_file.write_text(textwrap.dedent("""\ Westridge Marine Terminal: atb: akns: @@ -840,9 +835,7 @@ def test_get_oil_type_atb_tanker_cargo_spill( fraction_of_total: 0 other: fraction_of_total: 0 - """ - ) - ) + """)) monkeypatch.setitem(oil_attrs["files"], "CAD_origin", cargo_info_file) empty_file = data_dir / "empty_file" empty_file.write_text("") @@ -912,9 +905,7 @@ def test_get_oil_type_barge_cargo_spill( data_dir = tmp_path / "marine_transport_data" data_dir.mkdir() cargo_info_file = data_dir / "yaml_file" - cargo_info_file.write_text( - textwrap.dedent( - """\ + cargo_info_file.write_text(textwrap.dedent("""\ Westridge Marine Terminal: barge: akns: @@ -931,9 +922,7 @@ def test_get_oil_type_barge_cargo_spill( fraction_of_total: 0 other: fraction_of_total: 0 - """ - ) - ) + """)) monkeypatch.setitem(oil_attrs["files"], "CAD_origin", cargo_info_file) empty_file = data_dir / "empty_file" empty_file.write_text("") @@ -1056,12 +1045,10 @@ def test_write_csv_file(self, tmp_path): random_oil_spills.write_csv_file(df, str(out_csv)) - expected = textwrap.dedent( - """\ + expected = textwrap.dedent("""\ spill_date_hour,run_days 2016-08-19 18:00,7 2015-01-06 10:00,7 - """ - ) + """) assert out_csv.read_text() == expected diff --git a/tests/test_observations.py b/tests/test_observations.py index 66bab1a..596b8b7 100644 --- a/tests/test_observations.py +++ b/tests/test_observations.py @@ -17,6 +17,7 @@ """Unit tests for observations module.""" + import urllib.error import pandas