Skip to content

Commit

Permalink
feat: add pyink as a Python formatter (super-linter#6083)
Browse files Browse the repository at this point in the history
  • Loading branch information
nitobuendia committed Aug 27, 2024
1 parent 202d47f commit 5b13ace
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions README.md

Large diffs are not rendered by default.

Empty file added TEMPLATES/.python-pyink
Empty file.
1 change: 1 addition & 0 deletions dependencies/python/pyink.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyink==24.3.0
1 change: 1 addition & 0 deletions lib/functions/buildFileList.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" ] ||
Expand Down
1 change: 1 addition & 0 deletions lib/functions/linterCommands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/globals/languages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions lib/globals/linterCommandsOptions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}")
Expand Down
2 changes: 2 additions & 0 deletions lib/globals/linterRules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
1 change: 1 addition & 0 deletions scripts/linterVersions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
| PYTHON_FLAKE8 | Fail ❌ |
| PYTHON_ISORT | Fail ❌ |
| PYTHON_MYPY | Fail ❌ |
| PYTHON_PYINK | Fail ❌ |
| PYTHON_RUFF | Fail ❌ |
| R | Fail ❌ |
| RAKU | Fail ❌ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
| PYTHON_FLAKE8 | Fail ❌ |
| PYTHON_ISORT | Fail ❌ |
| PYTHON_MYPY | Fail ❌ |
| PYTHON_PYINK | Fail ❌ |
| PYTHON_RUFF | Fail ❌ |
| R | Fail ❌ |
| RAKU | Fail ❌ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
| PYTHON_FLAKE8 | Pass ✅ |
| PYTHON_ISORT | Pass ✅ |
| PYTHON_MYPY | Pass ✅ |
| PYTHON_PYINK | Pass ✅ |
| PYTHON_RUFF | Pass ✅ |
| R | Pass ✅ |
| RAKU | Pass ✅ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
| PYTHON_FLAKE8 | Pass ✅ |
| PYTHON_ISORT | Pass ✅ |
| PYTHON_MYPY | Pass ✅ |
| PYTHON_PYINK | Pass ✅ |
| PYTHON_RUFF | Pass ✅ |
| R | Pass ✅ |
| RAKU | Pass ✅ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
| PROTOBUF | Fail ❌ |
| PYTHON_BLACK | Pass ✅ |
| PYTHON_ISORT | Pass ✅ |
| PYTHON_PYINK | Pass ✅ |
| PYTHON_RUFF | Pass ✅ |
| RUBY | Fail ❌ |
| SCALAFMT | Pass ✅ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
| PROTOBUF | Fail ❌ |
| PYTHON_BLACK | Pass ✅ |
| PYTHON_ISORT | Pass ✅ |
| PYTHON_PYINK | Pass ✅ |
| PYTHON_RUFF | Pass ✅ |
| RUBY | Fail ❌ |
| RUST_2015 | Pass ✅ |
Expand Down
3 changes: 3 additions & 0 deletions test/inspec/super-linter/controls/super_linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
{ 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'); \
Expand Down Expand Up @@ -405,6 +406,7 @@
"flake8",
"isort",
"mypy",
"pyink",
"pylint",
"ruff",
"snakefmt",
Expand Down Expand Up @@ -511,6 +513,7 @@
"/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",
Expand Down
4 changes: 4 additions & 0 deletions test/linters/python_pyink/python_bad_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a=1;b=2
c=a+b
BROKEN_VAR=BROKEN_VAR
print(c)
4 changes: 4 additions & 0 deletions test/linters/python_pyink/python_good_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a = 1
b = 2
c = a + b
print(c)
1 change: 1 addition & 0 deletions test/testUtils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ LANGUAGES_WITH_FIX_MODE=(
"PROTOBUF"
"PYTHON_BLACK"
"PYTHON_ISORT"
"PYTHON_PYINK"
"PYTHON_RUFF"
"RUBY"
"RUST_2015"
Expand Down

0 comments on commit 5b13ace

Please sign in to comment.