Skip to content

Commit

Permalink
MNT: Switch to ruff as main linting tool
Browse files Browse the repository at this point in the history
Also switch over to isort for import order handling
  • Loading branch information
dopplershift committed Nov 4, 2024
1 parent de984f9 commit f13fc99
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 48 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Set up reviewdog
uses: reviewdog/action-setup@v1

- name: Run ruff
run: ruff check --output-format github

- name: Run flake8
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
21 changes: 7 additions & 14 deletions ci/linting_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
ruff==0.7.1

flake8==5.0.4
pycodestyle==2.9.1
pyflakes==2.5.0

flake8-bugbear==22.9.23
flake8-builtins==1.5.3
flake8-comprehensions==3.10.0
flake8-copyright==0.2.3
flake8-import-order==0.18.1
flake8-mutable==1.2.0
flake8-pep3101==1.3.0
flake8-print==5.0.0
flake8-quotes==3.3.1
flake8-simplify==0.19.3
pep8-naming==0.13.2
flake8-continuation==1.0.5
flake8-isort==6.1.1
isort==5.13.2
flake8-requirements==2.2.1

flake8-rst-docstrings==0.2.7
flake8-docstrings==1.6.0
pydocstyle==6.1.1

doc8==1.0.0
restructuredtext_lint==1.4.0
restructuredtext_lint==1.4.0
40 changes: 40 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,45 @@ extras = [
"Bug Tracker" = "https://github.com/Unidata/siphon/issues"
"Source Code" = "https://github.com/Unidata/siphon"

[tool.ruff]
line-length = 95
exclude = ["docs", "build", "src/siphon/cdmr/*_pb2.py"]
preview = true

[tool.ruff.lint]
select = ["A", "B", "C", "CPY001", "D", "E", "E226", "F", "G", "I", "N", "NPY", "PIE", "Q", "R", "S", "SIM", "T", "U", "W"]
# NPY201 ignores the use of 'trapz' false alarm
ignore = ["F405", "I001", "NPY201", "RET504", "RET505", "RET506", "RET507", "RUF100", "S314"]
explicit-preview-rules = true

[tool.ruff.lint.per-file-ignores]
"ci/filter_links.py" = ["E731", "T201", "S603", "S607"]
"examples/*.py" = ["D", "T201", "B018"]
"tests/*/*.py" = ["S101"]
"tests/test_*.py" = ["S101"]

[tool.ruff.lint.flake8-copyright]
# Needed to avoid need for spaces after a comma
notice-rgx = "(?i)Copyright\\s+(\\(C\\)\\s+)?\\d{4}([-,]\\d{4})*"
author = "Siphon Contributors"

[tool.ruff.lint.flake8-quotes]
inline-quotes = "single"
multiline-quotes = "double"

[tool.ruff.lint.isort]
known-first-party = ["siphon"]
force-single-line = false
relative-imports-order = "closest-to-furthest"
force-sort-within-sections = true
order-by-type = false
combine-as-imports = true

[tool.ruff.lint.mccabe]
max-complexity = 61

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

[tool.setuptools_scm]
version_scheme = "post-release"
45 changes: 11 additions & 34 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,38 +1,15 @@
[pycodestyle]
ignore = W503
max-line-length = 95

[flake8]
max-line-length = 95
application-import-names = siphon
import-order-style = google
copyright-check = True
copyright-author = Siphon Contributors
inline-quotes = single
multiline-quotes = double
rst-roles = class, data, doc, func, meth, mod
rst-directives = plot, versionchanged
docstring-convention = numpy
exclude =
docs
build
src/siphon/cdmr/ncStream_pb2.py
src/siphon/cdmr/cdmrfeature_pb2.py
select = A B C D E F H I M Q RST S T W B902
ignore = F405 W503 RST902 SIM
per-file-ignores = examples/*.py: D T201
tutorials/*.py: D T201

[tool:pytest]
norecursedirs = build docs

[doc8]
ignore-path = docs/build,docs/api
max-line-length = 95

[bdist_wheel]
# This flag says that the code is written to work on both Python 2 and 3.
universal=1

[aliases]
test = pytest

[yapf]
based_on_style = pep8
column_limit = 90
known-modules = netcdf4:[netCDF4]
exclude = docs build
select = E301 E302 E303 E304 E305 E306 I R
ignore = F405 W503 RST902 SIM106
per-file-ignores = src/siphon/_version.py: I900
src/siphon/testing.py: I900
ci/filter_links.py: E731
1 change: 1 addition & 0 deletions src/siphon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@

# Version import needs to come first so everyone else can pull on import
from ._version import get_version

__version__ = get_version()
del get_version

0 comments on commit f13fc99

Please sign in to comment.