diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 69f1b6d4e5..206392a999 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,9 +13,11 @@ repos: rev: v0.7.4 hooks: - id: ruff + name: ruff lint (.py) args: [--fix, --show-fixes] + types_or: [python] - id: ruff - name: ruff (isort jupyter) + name: ruff isort (.ipynb) args: [--select, I, --fix] types_or: [jupyter] - id: ruff-format diff --git a/docs/examples/documentation_indexing.ipynb b/docs/examples/documentation_indexing.ipynb index a6aac5cb2a..2836d729f1 100644 --- a/docs/examples/documentation_indexing.ipynb +++ b/docs/examples/documentation_indexing.ipynb @@ -54,9 +54,9 @@ "metadata": {}, "outputs": [], "source": [ + "import warnings\n", "from glob import glob\n", "from os import path\n", - "import warnings\n", "\n", "import numpy as np\n", "\n", diff --git a/docs/examples/example_brownian.py b/docs/examples/example_brownian.py index a760279bf4..370bd843f7 100644 --- a/docs/examples/example_brownian.py +++ b/docs/examples/example_brownian.py @@ -1,9 +1,10 @@ from datetime import timedelta import numpy as np -import parcels import pytest +import parcels + ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle} diff --git a/docs/examples/example_dask_chunk_OCMs.py b/docs/examples/example_dask_chunk_OCMs.py index 9a4cf7f53b..e60f00c848 100644 --- a/docs/examples/example_dask_chunk_OCMs.py +++ b/docs/examples/example_dask_chunk_OCMs.py @@ -4,8 +4,9 @@ import dask import numpy as np -import parcels import pytest + +import parcels from parcels.tools.statuscodes import DaskChunkingError ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle} diff --git a/docs/examples/example_decaying_moving_eddy.py b/docs/examples/example_decaying_moving_eddy.py index d77648c11a..46bc10d5c6 100644 --- a/docs/examples/example_decaying_moving_eddy.py +++ b/docs/examples/example_decaying_moving_eddy.py @@ -1,9 +1,10 @@ from datetime import timedelta import numpy as np -import parcels import pytest +import parcels + ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle} # Define some constants. diff --git a/docs/examples/example_globcurrent.py b/docs/examples/example_globcurrent.py index b4049256bd..d310a9883a 100755 --- a/docs/examples/example_globcurrent.py +++ b/docs/examples/example_globcurrent.py @@ -2,10 +2,11 @@ from glob import glob import numpy as np -import parcels import pytest import xarray as xr +import parcels + ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle} diff --git a/docs/examples/example_mitgcm.py b/docs/examples/example_mitgcm.py index f0f6a62c6c..95fec26ed7 100644 --- a/docs/examples/example_mitgcm.py +++ b/docs/examples/example_mitgcm.py @@ -3,9 +3,10 @@ from typing import Literal import numpy as np -import parcels import xarray as xr +import parcels + ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle} diff --git a/docs/examples/example_moving_eddies.py b/docs/examples/example_moving_eddies.py index 2b329ca485..1d238aad49 100644 --- a/docs/examples/example_moving_eddies.py +++ b/docs/examples/example_moving_eddies.py @@ -4,9 +4,10 @@ from datetime import timedelta import numpy as np -import parcels import pytest +import parcels + ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle} method = { "RK4": parcels.AdvectionRK4, diff --git a/docs/examples/example_nemo_curvilinear.py b/docs/examples/example_nemo_curvilinear.py index d5a5b5c193..e394573313 100644 --- a/docs/examples/example_nemo_curvilinear.py +++ b/docs/examples/example_nemo_curvilinear.py @@ -5,9 +5,10 @@ from glob import glob import numpy as np -import parcels import pytest +import parcels + ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle} advection = {"RK4": parcels.AdvectionRK4, "AA": parcels.AdvectionAnalytical} diff --git a/docs/examples/example_ofam.py b/docs/examples/example_ofam.py index c0fad50c29..791d890ffd 100644 --- a/docs/examples/example_ofam.py +++ b/docs/examples/example_ofam.py @@ -2,10 +2,11 @@ from datetime import timedelta import numpy as np -import parcels import pytest import xarray as xr +import parcels + ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle} diff --git a/docs/examples/example_peninsula.py b/docs/examples/example_peninsula.py index 5b17469bdc..dfd65c146c 100644 --- a/docs/examples/example_peninsula.py +++ b/docs/examples/example_peninsula.py @@ -4,9 +4,10 @@ from datetime import timedelta import numpy as np -import parcels import pytest +import parcels + ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle} method = { "RK4": parcels.AdvectionRK4, diff --git a/docs/examples/example_radial_rotation.py b/docs/examples/example_radial_rotation.py index 00bc866338..509e197649 100644 --- a/docs/examples/example_radial_rotation.py +++ b/docs/examples/example_radial_rotation.py @@ -2,9 +2,10 @@ from datetime import timedelta import numpy as np -import parcels import pytest +import parcels + ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle} diff --git a/docs/examples/example_stommel.py b/docs/examples/example_stommel.py index 56b499adb9..58150eec6c 100755 --- a/docs/examples/example_stommel.py +++ b/docs/examples/example_stommel.py @@ -3,9 +3,10 @@ from datetime import timedelta import numpy as np -import parcels import pytest +import parcels + ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle} method = { "RK4": parcels.AdvectionRK4, diff --git a/docs/examples/tutorial_croco_3D.ipynb b/docs/examples/tutorial_croco_3D.ipynb index f20a232359..7194025da8 100644 --- a/docs/examples/tutorial_croco_3D.ipynb +++ b/docs/examples/tutorial_croco_3D.ipynb @@ -35,11 +35,13 @@ "outputs": [], "source": [ "import os\n", - "import parcels\n", - "import numpy as np\n", + "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", "import xarray as xr\n", "\n", + "import parcels\n", + "\n", "example_dataset_folder = parcels.download_example_dataset(\"CROCOidealized_data\")\n", "file = os.path.join(example_dataset_folder, \"CROCO_idealized.nc\")" ] diff --git a/docs/examples/tutorial_nemo_3D.ipynb b/docs/examples/tutorial_nemo_3D.ipynb index 112e093bb9..2afae24644 100644 --- a/docs/examples/tutorial_nemo_3D.ipynb +++ b/docs/examples/tutorial_nemo_3D.ipynb @@ -54,9 +54,9 @@ } ], "source": [ + "import warnings\n", "from datetime import timedelta\n", "from glob import glob\n", - "import warnings\n", "\n", "import matplotlib.pyplot as plt\n", "import xarray as xr\n", diff --git a/docs/examples/tutorial_timestamps.ipynb b/docs/examples/tutorial_timestamps.ipynb index 6cc85f0b95..28f3cc709e 100644 --- a/docs/examples/tutorial_timestamps.ipynb +++ b/docs/examples/tutorial_timestamps.ipynb @@ -14,8 +14,8 @@ "metadata": {}, "outputs": [], "source": [ - "from glob import glob\n", "import warnings\n", + "from glob import glob\n", "\n", "import numpy as np\n", "\n", diff --git a/pyproject.toml b/pyproject.toml index 5e5c2106f2..5a213f72d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,8 +68,6 @@ filterwarnings = [ line-length = 120 [tool.ruff.lint] -exclude = ["*.ipynb"] - select = [ "D", # pydocstyle "E", # Error @@ -132,6 +130,9 @@ ignore = [ [tool.ruff.lint.pydocstyle] convention = "numpy" +[tool.ruff.lint.isort] +known-first-party = ["parcels"] + [tool.mypy] files = [ "parcels/compilation/codegenerator.py",