Skip to content

Commit

Permalink
Replace isort with ruff (SciTools#5633)
Browse files Browse the repository at this point in the history
* Replace isort with ruff

* ruff isort changes

* add whatsnew entry

* remove tool.isort configuration
  • Loading branch information
bjlittle authored Dec 13, 2023
1 parent 0cdead6 commit 2b764a3
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 34 deletions.
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ repos:
- id: flake8
types: [file, python]

- repo: https://github.com/pycqa/isort
rev: 5.13.0
hooks:
- id: isort
types: [file, python]
args: [--filter-files]

- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
Expand Down
4 changes: 0 additions & 4 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ lint.ignore = [
# https://docs.astral.sh/ruff/rules/#mccabe-c90
"C90",

# isort (I)
# https://docs.astral.sh/ruff/rules/#isort-i
"I",

# pep8-naming (N)
# https://docs.astral.sh/ruff/rules/#pep8-naming-n
"N",
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/cperf/equality.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"""
Equality benchmarks for the CPerf scheme of the UK Met Office's NG-VAT project.
"""
from . import SingleDiagnosticMixin
from .. import on_demand_benchmark
from . import SingleDiagnosticMixin


class EqualityMixin(SingleDiagnosticMixin):
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/cperf/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"""
File loading benchmarks for the CPerf scheme of the UK Met Office's NG-VAT project.
"""
from . import SingleDiagnosticMixin
from .. import on_demand_benchmark
from . import SingleDiagnosticMixin


@on_demand_benchmark
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/cperf/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

from iris import save

from . import _N_CUBESPHERE_UM_EQUIVALENT, _UM_DIMS_YX
from .. import TrackAddedMemoryAllocation, on_demand_benchmark
from ..generate_data.ugrid import make_cube_like_2d_cubesphere, make_cube_like_umfield
from . import _N_CUBESPHERE_UM_EQUIVALENT, _UM_DIMS_YX


@on_demand_benchmark
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/sperf/equality.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"""
Equality benchmarks for the SPerf scheme of the UK Met Office's NG-VAT project.
"""
from . import FileMixin
from .. import on_demand_benchmark
from . import FileMixin


@on_demand_benchmark
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/sperf/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"""
File loading benchmarks for the SPerf scheme of the UK Met Office's NG-VAT project.
"""
from . import FileMixin
from .. import on_demand_benchmark
from . import FileMixin


@on_demand_benchmark
Expand Down
1 change: 1 addition & 0 deletions docs/src/common_links.inc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
.. _pull requests: https://github.com/SciTools/iris/pulls
.. _Read the Docs: https://scitools-iris.readthedocs.io/en/latest/
.. _readthedocs.yml: https://github.com/SciTools/iris/blob/main/requirements/readthedocs.yml
.. _ruff: https://github.com/astral-sh/ruff
.. _SciTools: https://github.com/SciTools
.. _scitools-iris: https://pypi.org/project/scitools-iris/
.. _sphinx: https://www.sphinx-doc.org/en/master/
Expand Down
5 changes: 4 additions & 1 deletion docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ This document explains the changes made to Iris for this release
lazy data from file. This will also speed up coordinate comparison.
(:pull:`5610`)


🔥 Deprecations
===============

Expand Down Expand Up @@ -134,6 +135,7 @@ This document explains the changes made to Iris for this release

#. `@bouweandela`_ updated all hyperlinks to https. (:pull:`5621`)


💼 Internal
===========

Expand Down Expand Up @@ -175,6 +177,8 @@ This document explains the changes made to Iris for this release
#. `@bjlittle`_ configured the ``line-length = 88`` for `black`_, `isort`_
and `ruff`_. (:pull:`5632`)

#. `@bjlittle`_ replaced `isort`_ with `ruff`_. (:pull:`5633`)


.. comment
Whatsnew author names (@github name) in alphabetical order. Note that,
Expand All @@ -190,5 +194,4 @@ This document explains the changes made to Iris for this release
.. _NEP29 Drop Schedule: https://numpy.org/neps/nep-0029-deprecation_policy.html#drop-schedule
.. _codespell: https://github.com/codespell-project/codespell
.. _ruff: https://github.com/astral-sh/ruff
.. _split attributes project: https://github.com/orgs/SciTools/projects/5?pane=info
2 changes: 1 addition & 1 deletion lib/iris/common/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from dask.array.core import broadcast_shapes
import numpy as np

from . import LENIENT
from ..config import get_logger
from . import LENIENT

__all__ = ["Resolve"]

Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/experimental/test_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# See LICENSE in the root of the repository for full licensing details.

import iris.tests as tests # isort:skip
import PIL.Image
import numpy as np
import PIL.Image

import iris

Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/graphics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def repos_equal(repo1: Dict[str, str], repo2: Dict[str, str]) -> bool:


def get_phash(input: Path) -> str:
from PIL import Image
import imagehash
from PIL import Image

return imagehash.phash(Image.open(input), hash_size=HASH_SIZE)

Expand Down
18 changes: 4 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ ignore = [
"ALL",
]

[tool.ruff.lint.isort]
force-sort-within-sections = true
known-first-party = ["iris"]

[tool.ruff.lint.pydocstyle]
convention = "numpy"

Expand Down Expand Up @@ -125,20 +129,6 @@ extend-exclude = '''
)
'''

[tool.isort]
force_sort_within_sections = "True"
known_first_party = "iris"
line_length = 88
profile = "black"
extend_skip = [
"_build",
"generated",
"sphinxext",
"tools",
]
skip_gitignore = "True"
verbose = "False"

[tool.pytest.ini_options]
addopts = "-ra"
testpaths = "lib/iris"
Expand Down

0 comments on commit 2b764a3

Please sign in to comment.