OpenSenseAction / pypwsqc

Python package for quality control (QC) of data from personal weather stations (PWS)
https://pypwsqc.readthedocs.io
BSD 3-Clause "New" or "Revised" License
0 stars 3 forks source link

Add ruff linting for docstring #8

Closed cchwala closed 5 months ago

cchwala commented 7 months ago

Currently docstring are not linted. I did some test and the default behavior for ruff with including all "D" rules is a bit too strict IMO. Also tests should be excluded from docstring checks since they typically do not have a docstring and also do not need one.

Setting a line length of 88, like black does, also makes sense IMO.

I found a config here that seems to be a good compromise:

[tool.ruff]
line-length = 88
target-version = "py38"
# https://beta.ruff.rs/docs/rules/
extend-select = [
    "E",    # style errors
    "W",    # style warnings
    "F",    # flakes
    "D",    # pydocstyle
    "I",    # isort
    "U",    # pyupgrade
    # "S",    # bandit
    "C",    # flake8-comprehensions
    "B",    # flake8-bugbear
    "A001", # flake8-builtins
    "RUF",  # ruff-specific rules
]
# I do this to get numpy-style docstrings AND retain
# D417 (Missing argument descriptions in the docstring)
# otherwise, see:
# https://beta.ruff.rs/docs/faq/#does-ruff-support-numpy-or-google-style-docstrings
# https://github.com/charliermarsh/ruff/issues/2606
extend-ignore = [
    "D100", # Missing docstring in public module
    "D107", # Missing docstring in __init__
    "D203", # 1 blank line required before class docstring
    "D212", # Multi-line docstring summary should start at the first line
    "D213", # Multi-line docstring summary should start at the second line
    "D401", # First line should be in imperative mood
    "D413", # Missing blank line after last section
    "D416", # Section name should end with a colon
]

[tool.ruff.per-file-ignores]
"tests/*.py" = ["D", "S"]
"setup.py" = ["D"]
cchwala commented 5 months ago

Maybe that will be sufficient

[tool.ruff.lint]
select = ["D"]

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