diff --git a/packages/essimaging/pyproject.toml b/packages/essimaging/pyproject.toml index 71ee292f..7cb97e10 100644 --- a/packages/essimaging/pyproject.toml +++ b/packages/essimaging/pyproject.toml @@ -91,43 +91,6 @@ filterwarnings = [ 'ignore:\n Sentinel is not a public part of the traitlets API:DeprecationWarning' ] -[tool.ruff] -line-length = 88 -extend-include = ["*.ipynb"] -extend-exclude = [ - ".*", "__pycache__", "build", "dist", "install", -] - -[tool.ruff.lint] -# See https://docs.astral.sh/ruff/rules/ -select = ["B", "C4", "DTZ", "E", "F", "G", "I", "PERF", "PGH", "PT", "PYI", "RUF", "S", "T20", "UP", "W"] -ignore = [ - # Conflict with ruff format, see - # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules - "COM812", "COM819", "D206", "D300", "E111", "E114", "E117", "ISC001", "ISC002", "Q000", "Q001", "Q002", "Q003", "W191", -] -fixable = ["B010", "I001", "PT001", "RUF022"] -isort.known-first-party = ["ess.imaging"] -pydocstyle.convention = "numpy" - -[tool.ruff.lint.per-file-ignores] -# those files have an increased risk of relying on import order -"tests/*" = [ - "S101", # asserts are fine in tests - "B018", # 'useless expressions' are ok because some tests just check for exceptions -] -"*.ipynb" = [ - "E501", # longer lines are sometimes more readable - "F403", # *-imports used with domain types - "F405", # linter may fail to find names because of *-imports - "I", # we don't collect imports at the top - "S101", # asserts are used for demonstration and are safe in notebooks - "T201", # printing is ok for demonstration purposes -] - -[tool.ruff.format] -quote-style = "preserve" - [tool.mypy] strict = true ignore_missing_imports = true diff --git a/packages/essimaging/src/ess/imaging/masking.py b/packages/essimaging/src/ess/imaging/masking.py index 387480be..2a6cc7bc 100644 --- a/packages/essimaging/src/ess/imaging/masking.py +++ b/packages/essimaging/src/ess/imaging/masking.py @@ -5,6 +5,7 @@ """ import scipp as sc + from ess.reduce.nexus.types import RawDetector from ..imaging.types import CorrectedDetector, MaskingRules, RunType diff --git a/packages/essimaging/src/ess/imaging/types.py b/packages/essimaging/src/ess/imaging/types.py index b1fbf109..4d3a9614 100644 --- a/packages/essimaging/src/ess/imaging/types.py +++ b/packages/essimaging/src/ess/imaging/types.py @@ -6,6 +6,7 @@ import sciline import scipp as sc + from ess.reduce.nexus import types as reduce_t from ess.reduce.uncertainty import UncertaintyBroadcastMode as _UncertaintyBroadcastMode from ess.reduce.unwrap import types as unwrap_t diff --git a/packages/essimaging/src/ess/odin/workflows.py b/packages/essimaging/src/ess/odin/workflows.py index 277b39f7..30550434 100644 --- a/packages/essimaging/src/ess/odin/workflows.py +++ b/packages/essimaging/src/ess/odin/workflows.py @@ -5,6 +5,7 @@ """ import sciline + from ess.reduce.unwrap.workflow import GenericUnwrapWorkflow from ..imaging.types import ( diff --git a/packages/essimaging/src/ess/tbl/orca.py b/packages/essimaging/src/ess/tbl/orca.py index 45c6fda9..30a5f520 100644 --- a/packages/essimaging/src/ess/tbl/orca.py +++ b/packages/essimaging/src/ess/tbl/orca.py @@ -6,6 +6,7 @@ import sciline as sl import scipp as sc + from ess.reduce.nexus import GenericNeXusWorkflow, load_from_path from ess.reduce.nexus.types import ( NeXusDetectorName, diff --git a/packages/essimaging/src/ess/tbl/workflow.py b/packages/essimaging/src/ess/tbl/workflow.py index 9222af38..7316b84b 100644 --- a/packages/essimaging/src/ess/tbl/workflow.py +++ b/packages/essimaging/src/ess/tbl/workflow.py @@ -5,6 +5,7 @@ """ import sciline + from ess.reduce.unwrap.workflow import GenericUnwrapWorkflow from ..imaging.types import ( diff --git a/packages/essimaging/src/ess/ymir/io.py b/packages/essimaging/src/ess/ymir/io.py index c56a2640..fdacc04b 100644 --- a/packages/essimaging/src/ess/ymir/io.py +++ b/packages/essimaging/src/ess/ymir/io.py @@ -11,9 +11,10 @@ import scipp as sc import scippnexus as snx import scitiff -from ess.reduce.nexus.types import FilePath from tifffile import imwrite +from ess.reduce.nexus.types import FilePath + from .types import ( DEFAULT_HISTOGRAM_PATH, HistogramModeDetectorsPath, diff --git a/packages/essimaging/tests/imaging/tools/analysis_test.py b/packages/essimaging/tests/imaging/tools/analysis_test.py index e126a540..ec488326 100644 --- a/packages/essimaging/tests/imaging/tools/analysis_test.py +++ b/packages/essimaging/tests/imaging/tools/analysis_test.py @@ -3,10 +3,10 @@ import numpy as np import pytest import scipp as sc +from ess import imaging as img from scipp.testing import assert_identical from scitiff.io import load_scitiff -from ess import imaging as img from ess.imaging.data import siemens_star_path diff --git a/packages/essimaging/tests/odin/data_reduction_test.py b/packages/essimaging/tests/odin/data_reduction_test.py index 489668d0..b74bb715 100644 --- a/packages/essimaging/tests/odin/data_reduction_test.py +++ b/packages/essimaging/tests/odin/data_reduction_test.py @@ -1,11 +1,11 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2025 Scipp contributors (https://github.com/scipp) +import ess.odin.data # noqa: F401 import pytest import sciline as sl - -import ess.odin.data # noqa: F401 from ess import odin + from ess.imaging.types import ( Filename, LookupTable, diff --git a/packages/essimaging/tests/tbl/data_reduction_test.py b/packages/essimaging/tests/tbl/data_reduction_test.py index 33067e49..0a96b648 100644 --- a/packages/essimaging/tests/tbl/data_reduction_test.py +++ b/packages/essimaging/tests/tbl/data_reduction_test.py @@ -1,14 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2025 Scipp contributors (https://github.com/scipp) +import ess.tbl.data # noqa: F401 import pytest import sciline as sl import scipp as sc -from ess.reduce import unwrap -from ess.reduce.nexus.types import AnyRun - -import ess.tbl.data # noqa: F401 from ess import tbl + from ess.imaging.types import ( Filename, LookupTable, @@ -18,6 +16,8 @@ SampleRun, WavelengthDetector, ) +from ess.reduce import unwrap +from ess.reduce.nexus.types import AnyRun @pytest.fixture(scope="module") diff --git a/packages/essimaging/tests/tbl/orca_test.py b/packages/essimaging/tests/tbl/orca_test.py index 425eb000..86069202 100644 --- a/packages/essimaging/tests/tbl/orca_test.py +++ b/packages/essimaging/tests/tbl/orca_test.py @@ -1,14 +1,15 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2025 Scipp contributors (https://github.com/scipp) +import ess.tbl.data # noqa: F401 import pytest import sciline as sl import scipp as sc import scippnexus as sx +from ess import tbl +from ess.tbl import orca from scipp.testing import assert_identical -import ess.tbl.data # noqa: F401 -from ess import tbl from ess.imaging.types import ( BackgroundSubtractedDetector, CorrectedDetector, @@ -25,7 +26,6 @@ SampleRun, UncertaintyBroadcastMode, ) -from ess.tbl import orca @pytest.fixture diff --git a/packages/essimaging/tests/ymir/image_normalize_test.py b/packages/essimaging/tests/ymir/image_normalize_test.py index b01fe361..07053648 100644 --- a/packages/essimaging/tests/ymir/image_normalize_test.py +++ b/packages/essimaging/tests/ymir/image_normalize_test.py @@ -2,8 +2,6 @@ # Copyright (c) 2024 Scipp contributors (https://github.com/scipp) import pytest import scipp as sc -from scipp.testing.assertions import assert_allclose, assert_identical - from ess.ymir.io import ( DarkCurrentImageStacks, OpenBeamImageStacks, @@ -29,6 +27,7 @@ normalize_sample_images, ) from ess.ymir.workflow import YmirImageNormalizationWorkflow +from scipp.testing.assertions import assert_allclose, assert_identical @pytest.fixture diff --git a/packages/essimaging/tests/ymir/io_test.py b/packages/essimaging/tests/ymir/io_test.py index 8f5f63ac..90653d15 100644 --- a/packages/essimaging/tests/ymir/io_test.py +++ b/packages/essimaging/tests/ymir/io_test.py @@ -2,8 +2,6 @@ # Copyright (c) 2024 Scipp contributors (https://github.com/scipp) import pytest import scipp as sc -from scipp.testing import assert_identical - from ess.ymir.data import ymir_lego_images_path from ess.ymir.io import ( FilePath, @@ -14,6 +12,7 @@ load_nexus_rotation_logs, ) from ess.ymir.types import DEFAULT_HISTOGRAM_PATH +from scipp.testing import assert_identical def test_nexus_histogram_mode_detector_loading_warnings() -> None: diff --git a/packages/essnmx/pyproject.toml b/packages/essnmx/pyproject.toml index 44d1f5e0..bf3b96d5 100644 --- a/packages/essnmx/pyproject.toml +++ b/packages/essnmx/pyproject.toml @@ -97,43 +97,6 @@ filterwarnings = [ "error", ] -[tool.ruff] -line-length = 88 -extend-include = ["*.ipynb"] -extend-exclude = [ - ".*", "__pycache__", "build", "dist", "install", -] - -[tool.ruff.lint] -# See https://docs.astral.sh/ruff/rules/ -select = ["B", "C4", "DTZ", "E", "F", "G", "I", "PERF", "PGH", "PT", "PYI", "RUF", "S", "T20", "UP", "W"] -ignore = [ - # Conflict with ruff format, see - # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules - "COM812", "COM819", "D206", "D300", "E111", "E114", "E117", "ISC001", "ISC002", "Q000", "Q001", "Q002", "Q003", "W191", -] -fixable = ["B010", "I001", "PT001", "RUF022"] -isort.known-first-party = ["ess.nmx"] -pydocstyle.convention = "numpy" - -[tool.ruff.lint.per-file-ignores] -# those files have an increased risk of relying on import order -"tests/*" = [ - "S101", # asserts are fine in tests - "B018", # 'useless expressions' are ok because some tests just check for exceptions -] -"*.ipynb" = [ - "E501", # longer lines are sometimes more readable - "F403", # *-imports used with domain types - "F405", # linter may fail to find names because of *-imports - "I", # we don't collect imports at the top - "S101", # asserts are used for demonstration and are safe in notebooks - "T201", # printing is ok for demonstration purposes -] - -[tool.ruff.format] -quote-style = "preserve" - [tool.mypy] strict = true ignore_missing_imports = true @@ -143,11 +106,3 @@ enable_error_code = [ "truthy-bool", ] warn_unreachable = true - -[tool.codespell] -ignore-words-list = [ - # Codespell wants "socioeconomic" which seems to be the standard spelling. - # But we use the word in our code of conduct which is the contributor covenant. - # Let's not modify it if we don't have to. - "socio-economic", -] diff --git a/packages/essnmx/src/ess/nmx/_nxlauetof_io.py b/packages/essnmx/src/ess/nmx/_nxlauetof_io.py index f21dea0a..54f1498d 100644 --- a/packages/essnmx/src/ess/nmx/_nxlauetof_io.py +++ b/packages/essnmx/src/ess/nmx/_nxlauetof_io.py @@ -4,9 +4,10 @@ import scipp as sc import scippnexus as snx -from ess.reduce.nexus.types import FilePath, NeXusFile from scippneutron.metadata import RadiationProbe, SourceType +from ess.reduce.nexus.types import FilePath, NeXusFile + from .types import ControlMode diff --git a/packages/essnmx/src/ess/nmx/executables.py b/packages/essnmx/src/ess/nmx/executables.py index e4492e31..490bace7 100644 --- a/packages/essnmx/src/ess/nmx/executables.py +++ b/packages/essnmx/src/ess/nmx/executables.py @@ -8,6 +8,7 @@ import numpy as np import scipp as sc import scippnexus as snx + from ess.reduce.nexus.types import Filename, NeXusName, RawDetector, SampleRun from ess.reduce.unwrap.types import LookupTable diff --git a/packages/essnmx/src/ess/nmx/mcstas/executables.py b/packages/essnmx/src/ess/nmx/mcstas/executables.py index 3bef4e6e..6f5981bf 100644 --- a/packages/essnmx/src/ess/nmx/mcstas/executables.py +++ b/packages/essnmx/src/ess/nmx/mcstas/executables.py @@ -8,6 +8,7 @@ import sciline as sl import scipp as sc + from ess.reduce.streaming import ( EternalAccumulator, MaxAccumulator, diff --git a/packages/essnmx/src/ess/nmx/mcstas/streaming.py b/packages/essnmx/src/ess/nmx/mcstas/streaming.py index dbf3da51..2ea46257 100644 --- a/packages/essnmx/src/ess/nmx/mcstas/streaming.py +++ b/packages/essnmx/src/ess/nmx/mcstas/streaming.py @@ -4,6 +4,7 @@ import scipp as sc import scippnexus as snx + from ess.reduce.streaming import Accumulator from .load import _validate_chunk_size, load_event_data_bank_name diff --git a/packages/essnmx/src/ess/nmx/types.py b/packages/essnmx/src/ess/nmx/types.py index 324cbfca..6363c7f0 100644 --- a/packages/essnmx/src/ess/nmx/types.py +++ b/packages/essnmx/src/ess/nmx/types.py @@ -7,9 +7,10 @@ import sciline as sl import scipp as sc import scippnexus as snx +from scippneutron.metadata import RadiationProbe, SourceType + from ess.reduce.nexus.types import RunType from ess.reduce.unwrap.types import LookupTable -from scippneutron.metadata import RadiationProbe, SourceType from ._display_helper import to_datagroup diff --git a/packages/essnmx/src/ess/nmx/workflows.py b/packages/essnmx/src/ess/nmx/workflows.py index c85d2c8e..cdf6496a 100644 --- a/packages/essnmx/src/ess/nmx/workflows.py +++ b/packages/essnmx/src/ess/nmx/workflows.py @@ -6,6 +6,8 @@ import scipp as sc import scippnexus as snx import tof +from scippneutron.conversion.tof import tof_from_wavelength + from ess.reduce.nexus.types import ( EmptyDetector, Filename, @@ -28,7 +30,6 @@ WavelengthDetector, ) from ess.reduce.workflow import register_workflow -from scippneutron.conversion.tof import tof_from_wavelength from .configurations import WorkflowConfig from .types import ( diff --git a/packages/essnmx/tests/executable_test.py b/packages/essnmx/tests/executable_test.py index e5025656..1165406c 100644 --- a/packages/essnmx/tests/executable_test.py +++ b/packages/essnmx/tests/executable_test.py @@ -321,9 +321,8 @@ def lut_file_path(tmp_path: pathlib.Path): """Fixture to provide the path to the small NMX NeXus file.""" from dataclasses import is_dataclass - from ess.reduce.unwrap import LookupTable - from ess.nmx.workflows import initialize_nmx_workflow + from ess.reduce.unwrap import LookupTable # Simply use the default workflow for testing. workflow = initialize_nmx_workflow(config=WorkflowConfig()) diff --git a/packages/essreduce/pyproject.toml b/packages/essreduce/pyproject.toml index 8254d111..487f37dd 100644 --- a/packages/essreduce/pyproject.toml +++ b/packages/essreduce/pyproject.toml @@ -94,43 +94,6 @@ filterwarnings = [ 'ignore:Jupyter is migrating its paths:DeprecationWarning', ] -[tool.ruff] -line-length = 88 -extend-include = ["*.ipynb"] -extend-exclude = [ - ".*", "__pycache__", "build", "dist", "install", -] - -[tool.ruff.lint] -# See https://docs.astral.sh/ruff/rules/ -select = ["B", "C4", "DTZ", "E", "F", "G", "I", "PERF", "PGH", "PT", "PYI", "RUF", "S", "T20", "UP", "W"] -ignore = [ - # Conflict with ruff format, see - # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules - "COM812", "COM819", "D206", "D300", "E111", "E114", "E117", "ISC001", "ISC002", "Q000", "Q001", "Q002", "Q003", "W191", -] -fixable = ["B010", "I001", "PT001", "RUF022"] -isort.known-first-party = ["ess.reduce"] -pydocstyle.convention = "numpy" - -[tool.ruff.lint.per-file-ignores] -# those files have an increased risk of relying on import order -"tests/*" = [ - "S101", # asserts are fine in tests - "B018", # 'useless expressions' are ok because some tests just check for exceptions -] -"*.ipynb" = [ - "E501", # longer lines are sometimes more readable - "F403", # *-imports used with domain types - "F405", # linter may fail to find names because of *-imports - "I", # we don't collect imports at the top - "S101", # asserts are used for demonstration and are safe in notebooks - "T201", # printing is ok for demonstration purposes -] - -[tool.ruff.format] -quote-style = "preserve" - [tool.mypy] strict = true ignore_missing_imports = true diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 00000000..936ef7ae --- /dev/null +++ b/ruff.toml @@ -0,0 +1,39 @@ +line-length = 88 +extend-include = ["*.ipynb"] +extend-exclude = [ + ".*", "__pycache__", "build", "dist", "install", +] + +[lint] +# See https://docs.astral.sh/ruff/rules/ +select = ["B", "C4", "DTZ", "E", "F", "G", "I", "PERF", "PGH", "PT", "PYI", "RUF", "S", "T20", "UP", "W"] +ignore = [ + # Conflict with ruff format, see + # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules + "COM812", "COM819", "D206", "D300", "E111", "E114", "E117", "ISC001", "ISC002", "Q000", "Q001", "Q002", "Q003", "W191", +] +fixable = ["B010", "I001", "PT001", "RUF022"] +isort.known-first-party = ["ess.imaging", "ess.nmx", "ess.reduce"] +pydocstyle.convention = "numpy" + +[lint.per-file-ignores] +# those files have an increased risk of relying on import order +"packages/*/tests/*" = [ + "S101", # asserts are fine in tests + "B018", # 'useless expressions' are ok because some tests just check for exceptions +] +"*.ipynb" = [ + "E501", # longer lines are sometimes more readable + "F403", # *-imports used with domain types + "F405", # linter may fail to find names because of *-imports + "I", # we don't collect imports at the top + "S101", # asserts are used for demonstration and are safe in notebooks + "T201", # printing is ok for demonstration purposes +] +"tools/*" = [ + "T201", # printing is ok for demonstration purposes +] + +[format] +quote-style = "preserve" +exclude = ["*.ipynb"]