From b18a2db931c15f86f6e2e98633b6294377d076b2 Mon Sep 17 00:00:00 2001 From: jhalbauer Date: Tue, 22 Oct 2024 15:49:48 +0200 Subject: [PATCH] rename ruff config file --- .github/workflows/linting.yml | 8 ++--- linting-config-examples/README.md | 4 +-- linting-config-examples/pyproject.toml | 45 -------------------------- linting-config-examples/ruff.toml | 44 +++++++++++++++++++++++++ pre_commit_hooks/linting.sh | 14 ++++---- 5 files changed, 57 insertions(+), 58 deletions(-) delete mode 100644 linting-config-examples/pyproject.toml create mode 100644 linting-config-examples/ruff.toml diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 37def8b..4bbeedd 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -160,13 +160,13 @@ jobs: pip3 install ruff==${{ inputs.ruff-version }} ruff --version - name: Configure ruff - if: ${{ hashFiles('pyproject.toml') == '' }} + if: ${{ hashFiles('ruff.toml') == '' }} run: | - echo "pyproject.toml does not exists. Will be downloaded." - wget https://raw.githubusercontent.com/mundialis/github-workflows/main/linting-config-examples/pyproject.toml + echo "ruff.toml does not exists. Will be downloaded." + wget https://raw.githubusercontent.com/mundialis/github-workflows/main/linting-config-examples/ruff.toml - name: Lint with ruff run: | - ruff check --config pyproject.toml . + ruff check --config ruff.toml . super-linter: name: super-linter runs-on: ubuntu-latest diff --git a/linting-config-examples/README.md b/linting-config-examples/README.md index d4cd662..b4a900b 100644 --- a/linting-config-examples/README.md +++ b/linting-config-examples/README.md @@ -23,8 +23,8 @@ same way and place them in your directory root to adjust. `pylint --rc-file=.pylintrc_allowed_to_fail .` ## ruff -ruff contains rules inspired by black, flake8, pylint and more and is extremely fast in linting and formatting Python code. Simply add a pyproject.toml config file to the root of your repository. -See example here or visit [official documentation](https://docs.astral.sh/ruff/). `ruff check --config pyproject.toml .` +ruff contains rules inspired by black, flake8, pylint and more and is extremely fast in linting and formatting Python code. Simply add a ruff.toml config file to the root of your repository. +See example here or visit [official documentation](https://docs.astral.sh/ruff/). `ruff check --config ruff.toml .` ## superlinter Superlinter is a wrapper for many different linters. Each has a different way to be configured. diff --git a/linting-config-examples/pyproject.toml b/linting-config-examples/pyproject.toml deleted file mode 100644 index 46c736c..0000000 --- a/linting-config-examples/pyproject.toml +++ /dev/null @@ -1,45 +0,0 @@ -[tool.black] -required-version >= '24' -line-length = 79 -target-version = ['py38', 'py39', 'py310', 'py311', 'py312'] - -# [tool.ruff.format] -# See https://docs.astral.sh/ruff/formatter/ -# quote-style = "double" -# indent-style= "tab" - -[tool.ruff] -required-version = ">=0.7.0" - -# In addition to the standard set of exclusions, omit the following files or folders. -extend-exclude = [ - ".git", - "__pycache__", - ".env", - ".venv", - "env", - "venv", - "ENV", - "env.bak", - "venv.bak", - "ctypes", - "pydispatch", -] - -# [tool.ruff.lint] -# See https://docs.astral.sh/ruff/rules/ -# select = [ -# "A", # flake8-builtins (A) -# "COM", # flake8-commas -# "PL", # Pylint -# ] - -# ignore = [ - # See https://docs.astral.sh/ruff/rules/ -# "E402", # module-import-not-at-top-of-file -# "E501", # line-too-long -# ] - -# [tool.ruff.lint.per-file-ignores] -# See https://docs.astral.sh/ruff/settings/#lint_per-file-ignores -# "lib_dop/r_dop_import_lib.py" = ["ERA001", "PLR2004"] diff --git a/linting-config-examples/ruff.toml b/linting-config-examples/ruff.toml new file mode 100644 index 0000000..189527d --- /dev/null +++ b/linting-config-examples/ruff.toml @@ -0,0 +1,44 @@ +# Ruff configuration file: ruff.toml + +# Define the required version for Ruff +required-version = ">=0.7.0" + +line-length = 79 + +# Specify directories or files to be excluded from Ruff linting, in addition to default exclusions +extend-exclude = [ + ".git", + "__pycache__", + ".env", + ".venv", + "env", + "venv", + "ENV", + "env.bak", + "venv.bak", + "ctypes", + "pydispatch", +] + +# Uncomment the following sections as needed + +# [format] +# Format settings for Ruff (quote-style and indent-style) +# quote-style = "double" +# indent-style= "tab" + +# [lint] +# Define linting rules selection and ignore list +# select = [ +# "A", # flake8-builtins (A) +# "COM", # flake8-commas +# "PL", # Pylint +# ] +# ignore = [ +# "E402", # module-import-not-at-top-of-file +# "E501", # line-too-long +# ] + +# [lint.per-file-ignores] +# Define file-specific linting rule ignores +# "lib_dop/r_dop_import_lib.py" = ["ERA001", "PLR2004"] diff --git a/pre_commit_hooks/linting.sh b/pre_commit_hooks/linting.sh index 2726f55..4015249 100755 --- a/pre_commit_hooks/linting.sh +++ b/pre_commit_hooks/linting.sh @@ -113,7 +113,7 @@ echo echo "flake8: `flake8 --version`" echo "pylint: `pylint --version`" echo "black: `black --version`" -echo "black: `ruff --version`" +echo "ruff: `ruff --version`" ######## # lint # @@ -192,19 +192,19 @@ if [ $RUN_RUFF != "FALSE" ] then echo echo "RUFF:" - if test -f "pyproject.toml" + if test -f "ruff.toml" then - echo "pyproject.toml exists" + echo "ruff.toml exists" else # Same behaviour as in workflow - echo "pyproject.toml does not exists. Will be downloaded." - wget https://raw.githubusercontent.com/mundialis/github-workflows/main/linting-config-examples/pyproject.toml + echo "ruff.toml does not exists. Will be downloaded." + wget https://raw.githubusercontent.com/mundialis/github-workflows/main/linting-config-examples/ruff.toml fi - ruff check --config pyproject.toml . + ruff check --config ruff.toml . if [ $? -ne 0 ] then RETURNCODE=1 - FAILINGSTEP="$FAILINGSTEP RUFF (run 'ruff check --config pyproject.toml .')" + FAILINGSTEP="$FAILINGSTEP RUFF (run 'ruff check --config ruff.toml .')" fi else echo