From f13fc992c7d23853877a62993067680e5c1b8df2 Mon Sep 17 00:00:00 2001 From: Ryan May Date: Fri, 1 Nov 2024 16:28:41 -0600 Subject: [PATCH] MNT: Switch to ruff as main linting tool Also switch over to isort for import order handling --- .github/workflows/linting.yml | 3 +++ ci/linting_requirements.txt | 21 ++++++---------- pyproject.toml | 40 +++++++++++++++++++++++++++++++ setup.cfg | 45 +++++++++-------------------------- src/siphon/__init__.py | 1 + 5 files changed, 62 insertions(+), 48 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 851bd3fbd..3e3727922 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -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 }} diff --git a/ci/linting_requirements.txt b/ci/linting_requirements.txt index cdd8b3e93..8dfa68b07 100644 --- a/ci/linting_requirements.txt +++ b/ci/linting_requirements.txt @@ -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 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index fdac8a76c..55c56cf15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index f97fd3b58..313082671 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/src/siphon/__init__.py b/src/siphon/__init__.py index e3ae2d6cb..ff112fea9 100644 --- a/src/siphon/__init__.py +++ b/src/siphon/__init__.py @@ -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