From 41aa7df8c44189a7c60f999aa049aa1ef7ca600d Mon Sep 17 00:00:00 2001 From: Brewster Malevich Date: Wed, 13 May 2026 15:24:07 -0700 Subject: [PATCH] Tune ruff config, using xarray's setup to start --- CHANGELOG.md | 1 + pyproject.toml | 31 +++++++++++++++++++++++++++++++ src/isku/__init__.py | 14 +++++++------- tests/smoke_test.py | 1 + 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aca504..1bce701 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improved README. - Improved CONTRIBUTING. - Add project URLs to package metadata. +- Various improvement to internal code formatting and style. ## [0.1.0] - 2026-05-06 diff --git a/pyproject.toml b/pyproject.toml index 86fa652..b7be47d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,3 +26,34 @@ dev = [ { include-group = "tests" }, "prek>=0.3.13", ] + +[tool.ruff.lint] +extend-select = [ + "YTT", # flake8-2020 + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "ISC", # flake8-implicit-str-concat + "PIE", # flake8-pie + "TID", # flake8-tidy-imports (absolute imports) + "PYI", # flake8-pyi + "SIM", # flake8-simplify + "FLY", # flynt + "I", # isort + "PERF", # Perflint + "W", # pycodestyle warnings + "PGH", # pygrep-hooks + "PLC", # Pylint Convention + "PLE", # Pylint Errors + "PLR", # Pylint Refactor + "PLW", # Pylint Warnings + "UP", # pyupgrade + "FURB", # refurb + "RUF", +] + +[tool.ruff.lint.isort] +known-first-party = ["isku"] + +[tool.ruff.lint.flake8-tidy-imports] +# Disallow all relative imports. +ban-relative-imports = "all" diff --git a/src/isku/__init__.py b/src/isku/__init__.py index 3e023d4..458ff8d 100644 --- a/src/isku/__init__.py +++ b/src/isku/__init__.py @@ -1,18 +1,18 @@ +from collections.abc import Callable from dataclasses import dataclass -from typing import Protocol, Callable +from typing import Protocol import xarray as xr - __all__ = [ + "ExtractionWorkflow", + "GridWeightingRegions", + "ProjectionWorkflow", + "RegionExtractor", "build_extraction_workflow", - "extract_regions", "build_projection_workflow", + "extract_regions", "project", - "GridWeightingRegions", - "ExtractionWorkflow", - "RegionExtractor", - "ProjectionWorkflow", ] diff --git a/tests/smoke_test.py b/tests/smoke_test.py index 0169c65..b0edd0e 100644 --- a/tests/smoke_test.py +++ b/tests/smoke_test.py @@ -3,6 +3,7 @@ """ import xarray as xr + import isku