From 2bfd65b6e86a9da8a53ef920aef3803d2cb7341e Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Thu, 5 Dec 2024 16:24:20 -0800 Subject: [PATCH] Replace flake8, isort and black for ruff Replace linters and autoformatters for ruff. --- .flake8 | 40 -------------------------------------- Makefile | 9 ++++----- choclo/prism/_utils.py | 6 +++--- env/requirements-style.txt | 13 +------------ environment.yml | 13 +------------ pyproject.toml | 24 +++++++++++++++++++++++ 6 files changed, 33 insertions(+), 72 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index b7fbefdd..00000000 --- a/.flake8 +++ /dev/null @@ -1,40 +0,0 @@ -# Configure flake8 - -[flake8] -max-line-length = 88 -max-doc-length = 88 -ignore = - # Too many leading '#' for block comment - E266, - # Line too long (82 > 79 characters) - E501, - # Do not use variables named 'I', 'O', or 'l' - E741, - # Line break before binary operator (conflicts with black) - W503, - # Functions too long. The kernels will end up a bit long but not complex. - CFQ001, - # Number of arguments. Kernels take only scalars (no lists or arrays) - CFQ002, -exclude = - .git, - __pycache__, - .ipynb_checkpoints, - doc/_build, -per-file-ignores = - # disable unused-imports errors on __init__.py - __init__.py: F401 - # disable unused arguments in kernel files - _kernels.py: U100 - -# Configure flake8-rst-docstrings -# ------------------------------- -# Add some roles used in our docstrings -rst-roles = - class, - func, - mod, - meth, - ref, -# Ignore "Unknown target name" raised on citations -extend-ignore = RST306 diff --git a/Makefile b/Makefile index b481a61e..c704b133 100644 --- a/Makefile +++ b/Makefile @@ -38,19 +38,18 @@ test_numba: rm -rvf $(TESTDIR) format: - isort $(CHECK_STYLE) - black $(CHECK_STYLE) + ruff check --select I --fix $(CHECK_STYLE) # fix isort errors + ruff format $(CHECK_STYLE) burocrata --extension=py $(CHECK_STYLE) check: check-format check-style check-format: - isort --check $(CHECK_STYLE) - black --check $(CHECK_STYLE) + ruff format --check $(CHECK_STYLE) burocrata --check --extension=py $(CHECK_STYLE) check-style: - flake8 $(CHECK_STYLE) + ruff check $(CHECK_STYLE) clean: find . -name "*.pyc" -exec rm -v {} \; diff --git a/choclo/prism/_utils.py b/choclo/prism/_utils.py index 2c43b172..1ba90133 100644 --- a/choclo/prism/_utils.py +++ b/choclo/prism/_utils.py @@ -251,7 +251,7 @@ def is_point_on_east_face( easting, northing, upward, - prism_west, # noqa: U100 + prism_west, # noqa: ARG001 prism_east, prism_south, prism_north, @@ -296,7 +296,7 @@ def is_point_on_north_face( upward, prism_west, prism_east, - prism_south, # noqa: U100 + prism_south, # noqa: ARG001 prism_north, prism_bottom, prism_top, @@ -341,7 +341,7 @@ def is_point_on_top_face( prism_east, prism_south, prism_north, - prism_bottom, # noqa: U100 + prism_bottom, # noqa: ARG001 prism_top, ): """ diff --git a/env/requirements-style.txt b/env/requirements-style.txt index 9dcec7cc..759503c9 100644 --- a/env/requirements-style.txt +++ b/env/requirements-style.txt @@ -1,13 +1,2 @@ -black -pathspec -isort -flake8 -flake8-bugbear -flake8-builtins -flake8-functions -flake8-mutable -flake8-rst-docstrings -flake8-simplify -flake8-unused-arguments -pep8-naming +ruff burocrata diff --git a/environment.yml b/environment.yml index ca823e77..8f06d398 100644 --- a/environment.yml +++ b/environment.yml @@ -24,17 +24,6 @@ dependencies: - jupyter-sphinx==0.5.* - matplotlib # Style - - black - - pathspec - - isort - - flake8 - - flake8-bugbear - - flake8-builtins - - flake8-functions - - flake8-mutable - - flake8-rst-docstrings - - flake8-simplify - - flake8-unused-arguments - - pep8-naming + - ruff - pip: - burocrata diff --git a/pyproject.toml b/pyproject.toml index 8ee75f87..136892de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,3 +62,27 @@ notice = ''' # # This code is part of the Fatiando a Terra project (https://www.fatiando.org) #''' + +[tool.ruff] +line-length = 88 +exclude = [ + "doc/_build", + "choclo/_version.py", +] + +[tool.ruff.lint] +select = [ + "E", # pycodestyle + "F", # Pyflakes + "UP", # pyupgrade + "B", # flake8-bugbear + "ARG", # unused arguments + # "SIM", # flake8-simplify + "I", # isort +] + +[tool.ruff.lint.per-file-ignores] +# disable unused-imports errors on __init__.py +"__init__.py" = ["F401"] +# disable unused arguments in kernel files +"_kernels.py" = ["ARG001"]