feat: add pyink as a Python formatter (#6083)

This commit is contained in:
Nito Buendia 2024-08-27 23:00:51 +08:00 committed by GitHub
parent 202d47fa8c
commit 5b13acee46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 33 additions and 3 deletions

View file

@ -30,6 +30,7 @@
"**/test/linters/python_flake8",
"**/test/linters/python_isort",
"**/test/linters/python_mypy",
"**/test/linters/python_pyink",
"**/test/linters/python_pylint",
"**/test/linters/python_ruff",
"**/test/linters/r",

View file

@ -404,6 +404,7 @@ ENV PATH="${PATH}:/venvs/cpplint/bin"
ENV PATH="${PATH}:/venvs/flake8/bin"
ENV PATH="${PATH}:/venvs/isort/bin"
ENV PATH="${PATH}:/venvs/mypy/bin"
ENV PATH="${PATH}:/venvs/pyink/bin"
ENV PATH="${PATH}:/venvs/pylint/bin"
ENV PATH="${PATH}:/venvs/ruff/bin"
ENV PATH="${PATH}:/venvs/snakefmt/bin"

View file

@ -57,7 +57,7 @@ Super-linter supports the following tools:
| **Amazon States Language** | [ASL Validator](https://github.com/ChristopheBougere/asl-validator) | See JSON formatters |
| **AWS CloudFormation templates** | [AWS CloudFormation Linter (cfn-lint)](https://github.com/aws-cloudformation/cfn-lint), [Checkov](https://www.checkov.io/) | See YAML formatters |
| **Azure Resource Manager (ARM)** | [Azure Resource Manager Template Toolkit (arm-ttk)](https://github.com/azure/arm-ttk), [Checkov](https://www.checkov.io/) | See JSON formatters |
| **C**, **C++++** | [cpp-lint](https://github.com/cpplint/cpplint) | [clang-format](https://clang.llvm.org/docs/ClangFormatStyleOptions.html) |
| **C**, **C++** | [cpp-lint](https://github.com/cpplint/cpplint) | [clang-format](https://clang.llvm.org/docs/ClangFormatStyleOptions.html) |
| **C#** | See Dotnet solutions | [dotnet format whitespace command](https://github.com/dotnet/format) |
| **CSS**, **SCSS**, **Sass** | [stylelint](https://stylelint.io/) | [Prettier](https://prettier.io/) |
| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | |
@ -92,7 +92,7 @@ Super-linter supports the following tools:
| **PHP** | [PHP built-in linter](https://www.php.net/manual/en/features.commandline.options.php), [PHP CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer), [PHPStan](https://phpstan.org/), [Psalm](https://psalm.dev/) | |
| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | |
| **Protocol Buffers (Protobuf)** | [protolint](https://github.com/yoheimuta/protolint) | |
| **Python3** | [pylint](https://pylint.pycqa.org/), [flake8](https://flake8.pycqa.org/en/latest/), [isort](https://pypi.org/project/isort/), [ruff](https://github.com/astral-sh/ruff) | [black](https://github.com/psf/black) |
| **Python3** | [pylint](https://pylint.pycqa.org/), [flake8](https://flake8.pycqa.org/en/latest/), [isort](https://pypi.org/project/isort/), [ruff](https://github.com/astral-sh/ruff) | [black](https://github.com/psf/black), [pyink](https://github.com/google/pyink) |
| **R** | [lintr](https://github.com/jimhester/lintr) | |
| **Raku** | [Raku](https://raku.org) | |
| **Renovate** | [renovate-config-validator](https://docs.renovatebot.com/config-validation/) | N/A |
@ -244,6 +244,7 @@ You can configure Super-linter using the following environment variables:
| **FIX_PROTOBUF** | `false` | Option to enable fix mode for `PROTOBUF`. |
| **FIX_PYTHON_BLACK** | `false` | Option to enable fix mode for `PYTHON_BLACK`. |
| **FIX_PYTHON_ISORT** | `false` | Option to enable fix mode for `PYTHON_ISORT`. |
| **FIX_PYTHON_PYINK** | `false` | Option to enable fix mode for `PYTHON_PYINK`. |
| **FIX_PYTHON_RUFF** | `false` | Option to enable fix mode for `PYTHON_RUFF`. |
| **FIX_RUBY** | `false` | Option to enable fix mode for `RUBY`. |
| **FIX_RUST_2015** | `false` | Option to enable fix mode for `RUST_2015`. |
@ -291,6 +292,7 @@ You can configure Super-linter using the following environment variables:
| **PYTHON_FLAKE8_CONFIG_FILE** | `.flake8` | Filename for [flake8 configuration](https://flake8.pycqa.org/en/latest/user/configuration.html) (ex: `.flake8`, `tox.ini`) |
| **PYTHON_ISORT_CONFIG_FILE** | `.isort.cfg` | Filename for [isort configuration](https://pycqa.github.io/isort/docs/configuration/config_files.html) (ex: `.isort.cfg`, `pyproject.toml`) |
| **PYTHON_MYPY_CONFIG_FILE** | `.mypy.ini` | Filename for [mypy configuration](https://mypy.readthedocs.io/en/stable/config_file.html) (ex: `.mypy.ini`, `setup.config`) |
| **PYTHON_PYINK_CONFIG_FILE** | `.python-pyink` | Filename for [pyink configuration](https://github.com/google/pyink?tab=readme-ov-file#how-do-i-use-pyink) (ex: `.isort.cfg`, `pyproject.toml`) |
| **PYTHON_PYLINT_CONFIG_FILE** | `.python-lint` | Filename for [pylint configuration](https://pylint.pycqa.org/en/latest/user_guide/run.html?highlight=rcfile#command-line-options) (ex: `.python-lint`, `.pylintrc`) |
| **PYTHON_RUFF_CONFIG_FILE** | `.ruff.toml` | Filename for [ruff configuration](https://docs.astral.sh/ruff/configuration/) |
| **RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES** | not set | Comma-separated filenames for [renovate shareable config preset](https://docs.renovatebot.com/config-presets/) (ex: `default.json`) |
@ -377,6 +379,7 @@ You can configure Super-linter using the following environment variables:
| **VALIDATE_PYTHON_FLAKE8** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: flake8) |
| **VALIDATE_PYTHON_ISORT** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: isort) |
| **VALIDATE_PYTHON_MYPY** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: mypy) |
| **VALIDATE_PYTHON_PYINK** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: pyink) |
| **VALIDATE_PYTHON_PYLINT** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: pylint) |
| **VALIDATE_PYTHON_RUFF** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: ruff) |
| **VALIDATE_R** | `true` | Flag to enable or disable the linting process of the R language. |

0
TEMPLATES/.python-pyink Normal file
View file

1
dependencies/python/pyink.txt vendored Normal file
View file

@ -0,0 +1 @@
pyink==24.3.0

View file

@ -469,6 +469,7 @@ BuildFileArrays() {
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PYTHON_ISORT"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PYTHON_PYLINT"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PYTHON_MYPY"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PYTHON_PYINK"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PYTHON_RUFF"
elif [ "${FILE_TYPE}" == "raku" ] || [ "${FILE_TYPE}" == "rakumod" ] ||
[ "${FILE_TYPE}" == "rakutest" ] || [ "${FILE_TYPE}" == "pm6" ] ||

View file

@ -132,6 +132,7 @@ LINTER_COMMANDS_ARRAY_PYTHON_PYLINT=(pylint --rcfile "${PYTHON_PYLINT_LINTER_RUL
LINTER_COMMANDS_ARRAY_PYTHON_FLAKE8=(flake8 --config="${PYTHON_FLAKE8_LINTER_RULES}")
LINTER_COMMANDS_ARRAY_PYTHON_ISORT=(isort --sp "${PYTHON_ISORT_LINTER_RULES}")
LINTER_COMMANDS_ARRAY_PYTHON_MYPY=(mypy --config-file "${PYTHON_MYPY_LINTER_RULES}" --install-types --non-interactive)
LINTER_COMMANDS_ARRAY_PYTHON_PYINK=(pyink --config "${PYTHON_PYINK_LINTER_RULES}")
LINTER_COMMANDS_ARRAY_PYTHON_RUFF=(ruff check --config "${PYTHON_RUFF_LINTER_RULES}")
LINTER_COMMANDS_ARRAY_R=(R --slave -e "\"lints <- lintr::lint('{}');print(lints);errors <- purrr::keep(lints, ~ .\\\$type == 'error');quit(save = 'no', status = if (length(errors) > 0) 1 else 0)\"")
LINTER_COMMANDS_ARRAY_RAKU=(raku)

View file

@ -29,7 +29,7 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CHECKOV' 'CLANG_FORMAT'
"MARKDOWN_PRETTIER"
'NATURAL_LANGUAGE' 'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN'
'PHP_PSALM' 'POWERSHELL' 'PROTOBUF' 'PYTHON_BLACK' 'PYTHON_PYLINT'
'PYTHON_FLAKE8' 'PYTHON_ISORT' 'PYTHON_MYPY' 'PYTHON_RUFF'
'PYTHON_FLAKE8' 'PYTHON_ISORT' 'PYTHON_MYPY' 'PYTHON_PYINK' 'PYTHON_RUFF'
'R' 'RAKU' 'RENOVATE' 'RUBY' 'RUST_2015'
'RUST_2018' 'RUST_2021' 'RUST_CLIPPY' 'SCALAFMT' 'SHELL_SHFMT'
'SNAKEMAKE_LINT' 'SNAKEMAKE_SNAKEFMT' 'STATES' 'SQLFLUFF' 'TEKTON'

View file

@ -27,6 +27,7 @@ JSX_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
MARKDOWN_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
PYTHON_BLACK_CHECK_ONLY_MODE_OPTIONS=(--diff --check)
PYTHON_ISORT_CHECK_ONLY_MODE_OPTIONS=(--diff --check)
PYTHON_PYINK_CHECK_ONLY_MODE_OPTIONS=(--diff --check)
RUST_2015_CHECK_ONLY_MODE_OPTIONS=("${RUSTFMT_CHECK_ONLY_MODE_OPTIONS[@]}")
RUST_2018_CHECK_ONLY_MODE_OPTIONS=("${RUSTFMT_CHECK_ONLY_MODE_OPTIONS[@]}")
RUST_2021_CHECK_ONLY_MODE_OPTIONS=("${RUSTFMT_CHECK_ONLY_MODE_OPTIONS[@]}")

View file

@ -78,6 +78,8 @@ PYTHON_ISORT_FILE_NAME="${PYTHON_ISORT_CONFIG_FILE:-.isort.cfg}"
# shellcheck disable=SC2034 # Variable is referenced indirectly
PYTHON_MYPY_FILE_NAME="${PYTHON_MYPY_CONFIG_FILE:-.mypy.ini}"
# shellcheck disable=SC2034 # Variable is referenced indirectly
PYTHON_PYINK_FILE_NAME="${PYTHON_PYINK_CONFIG_FILE:-.python-pyink}"
# shellcheck disable=SC2034 # Variable is referenced indirectly
PYTHON_PYLINT_FILE_NAME="${PYTHON_PYLINT_CONFIG_FILE:-.python-lint}"
# shellcheck disable=SC2034 # Variable is referenced indirectly
PYTHON_RUFF_FILE_NAME="${PYTHON_RUFF_CONFIG_FILE:-.ruff.toml}"

View file

@ -56,6 +56,7 @@ LINTER_NAMES_ARRAY['PYTHON_PYLINT']="pylint"
LINTER_NAMES_ARRAY['PYTHON_FLAKE8']="flake8"
LINTER_NAMES_ARRAY['PYTHON_ISORT']="isort"
LINTER_NAMES_ARRAY['PYTHON_MYPY']="mypy"
LINTER_NAMES_ARRAY['PYTHON_PYINK']="pyink"
LINTER_NAMES_ARRAY['PYTHON_RUFF']="ruff"
LINTER_NAMES_ARRAY['R']="R"
LINTER_NAMES_ARRAY['RAKU']="raku"

View file

@ -60,6 +60,7 @@
| PYTHON_FLAKE8 | Fail ❌ |
| PYTHON_ISORT | Fail ❌ |
| PYTHON_MYPY | Fail ❌ |
| PYTHON_PYINK | Fail ❌ |
| PYTHON_RUFF | Fail ❌ |
| R | Fail ❌ |
| RAKU | Fail ❌ |

View file

@ -66,6 +66,7 @@
| PYTHON_FLAKE8 | Fail ❌ |
| PYTHON_ISORT | Fail ❌ |
| PYTHON_MYPY | Fail ❌ |
| PYTHON_PYINK | Fail ❌ |
| PYTHON_RUFF | Fail ❌ |
| R | Fail ❌ |
| RAKU | Fail ❌ |

View file

@ -60,6 +60,7 @@
| PYTHON_FLAKE8 | Pass ✅ |
| PYTHON_ISORT | Pass ✅ |
| PYTHON_MYPY | Pass ✅ |
| PYTHON_PYINK | Pass ✅ |
| PYTHON_RUFF | Pass ✅ |
| R | Pass ✅ |
| RAKU | Pass ✅ |

View file

@ -66,6 +66,7 @@
| PYTHON_FLAKE8 | Pass ✅ |
| PYTHON_ISORT | Pass ✅ |
| PYTHON_MYPY | Pass ✅ |
| PYTHON_PYINK | Pass ✅ |
| PYTHON_RUFF | Pass ✅ |
| R | Pass ✅ |
| RAKU | Pass ✅ |

View file

@ -30,6 +30,7 @@
| PROTOBUF | Fail ❌ |
| PYTHON_BLACK | Pass ✅ |
| PYTHON_ISORT | Pass ✅ |
| PYTHON_PYINK | Pass ✅ |
| PYTHON_RUFF | Pass ✅ |
| RUBY | Fail ❌ |
| SCALAFMT | Pass ✅ |

View file

@ -35,6 +35,7 @@
| PROTOBUF | Fail ❌ |
| PYTHON_BLACK | Pass ✅ |
| PYTHON_ISORT | Pass ✅ |
| PYTHON_PYINK | Pass ✅ |
| PYTHON_RUFF | Pass ✅ |
| RUBY | Fail ❌ |
| RUST_2015 | Pass ✅ |

View file

@ -186,6 +186,7 @@ control "super-linter-installed-commands" do
{ linter_name: "protolint", version_option: "version"},
{ linter_name: "psalm"},
{ linter_name: "pwsh"},
{ linter_name: "pyink"},
{ linter_name: "pylint"},
{ linter_name: "R", version_command: "R --slave -e \"r_ver <- R.Version()\\$version.string; \
lintr_ver <- packageVersion('lintr'); \
@ -405,6 +406,7 @@ control "super-linter-installed-pypi-packages" do
"flake8",
"isort",
"mypy",
"pyink",
"pylint",
"ruff",
"snakefmt",
@ -511,6 +513,7 @@ control "super-linter-validate-files" do
"/action/lib/.automation/.protolintrc.yml",
"/action/lib/.automation/.python-black",
"/action/lib/.automation/.python-lint",
"/action/lib/.automation/.python-pyink",
"/action/lib/.automation/.ruby-lint.yml",
"/action/lib/.automation/.ruff.toml",
"/action/lib/.automation/.scalafmt.conf",

View file

@ -0,0 +1,4 @@
a=1;b=2
c=a+b
BROKEN_VAR=BROKEN_VAR
print(c)

View file

@ -0,0 +1,4 @@
a = 1
b = 2
c = a + b
print(c)

View file

@ -53,6 +53,7 @@ LANGUAGES_WITH_FIX_MODE=(
"PROTOBUF"
"PYTHON_BLACK"
"PYTHON_ISORT"
"PYTHON_PYINK"
"PYTHON_RUFF"
"RUBY"
"RUST_2015"