Skip to content

Commit

Permalink
Fix Ruff linting config (#265)
Browse files Browse the repository at this point in the history
Ruff wasn't correctly running and applying all of the rules since the formatter related changes were applied.
  • Loading branch information
abkfenris committed May 2, 2024
1 parent 5413cba commit b44708f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
26 changes: 22 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand All @@ -58,6 +61,9 @@ line-length = 100
skip-string-normalization = true

[tool.ruff]
line-length = 100

[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"C",
Expand All @@ -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",
Expand All @@ -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 = [
Expand Down Expand Up @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_zarr_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b44708f

Please sign in to comment.