From b44708f63203e4f26ba465e7ec7aa2fc0c441eae Mon Sep 17 00:00:00 2001 From: Alex Kerney Date: Thu, 2 May 2024 15:36:12 -0400 Subject: [PATCH] Fix Ruff linting config (#265) Ruff wasn't correctly running and applying all of the rules since the formatter related changes were applied. --- pyproject.toml | 26 ++++++++++++++++++++++---- tests/test_zarr_compat.py | 2 +- tests/utils.py | 4 ++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 435f85dc..b824d84b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,9 @@ module_version = "xpublish.plugins.included.module_version:ModuleVersionPlugin" plugin_info = "xpublish.plugins.included.plugin_info:PluginInfoPlugin" zarr = "xpublish.plugins.included.zarr:ZarrPlugin" +[tool.setuptools] +packages = ["xpublish"] + [tool.setuptools.dynamic] dependencies = { file = ["requirements.txt"] } @@ -58,6 +61,9 @@ line-length = 100 skip-string-normalization = true [tool.ruff] +line-length = 100 + +[tool.ruff.lint] select = [ "B", # flake8-bugbear "C", @@ -73,6 +79,7 @@ ignore = [ "D100", # Missing docstring in public module "D107", # Missing docstring in `__init__` "D104", # Missing docstring in public package + "D105", # Missing docstring in magic method # "E203", # "E266", "E501", @@ -81,17 +88,28 @@ ignore = [ "E402", "C901", ] -line-length = 100 exclude = [ "tests/", "docs/", ] -[tool.ruff.mccabe] +[tool.ruff.lint.per-file-ignores] +"tests/*" = [ + "D103", # Missing docstring in public function + "D205", # blank line between summary and description + "D415", # first line should end with punctuation +] +"docs/*" = [ + "D101", # missing docstring in public class + "D102", # missing docstring in public method + "D103", # missing docstring in public function +] + +[tool.ruff.lint.mccabe] # Unlike Flake8, default to a complexity level of 10. max-complexity = 18 -[tool.ruff.isort] +[tool.ruff.lint.isort] combine-as-imports = true known-first-party = ["xpublish"] known-third-party = [ @@ -121,7 +139,7 @@ convention = "google" inline-quotes = "single" docstring-quotes = "double" -[tool.ruff.flake8-bugbear] +[tool.ruff.lint.flake8-bugbear] # Allow fastapi.Depends and other dependency injection style function arguments extend-immutable-calls = ["fastapi.Depends", "fastapi.Query", "fastapi.Path"] diff --git a/tests/test_zarr_compat.py b/tests/test_zarr_compat.py index 994191b8..b7495cdb 100644 --- a/tests/test_zarr_compat.py +++ b/tests/test_zarr_compat.py @@ -101,7 +101,7 @@ def test_zmetadata_identical_coords( def test_zmetadata_identical_coords_sorted( start, end, freq, nlats, nlons, var_const, calendar, use_cftime ): - """Test that zmetadata passes when coords are explicitly sorted""" + """Test that zmetadata passes when coords are explicitly sorted.""" ds = create_dataset( start=start, end=end, diff --git a/tests/utils.py b/tests/utils.py index 57cdc813..409ba9af 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -11,7 +11,7 @@ class TestMapper(TestClient, BaseStore): - """A simple subclass to support getitem syntax on Starlette TestClient Objects""" + """A simple subclass to support getitem syntax on Starlette TestClient Objects.""" def __getitem__(self, key): zarr_key = f'/zarr/{key}' @@ -46,7 +46,7 @@ def create_dataset( var_const=None, use_xy_dim=False, ): - """Utility function for creating test data""" + """Utility function for creating test data.""" if use_cftime: end = xr.coding.cftime_offsets.to_cftime_datetime(end, calendar=calendar) dates = xr.cftime_range(start=start, end=end, freq=freq, calendar=calendar)