diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9a18883b..5827244c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -147,6 +147,7 @@ updates: - flake8 - isort - mypy + - nbqa - pyink - pylint - ruff diff --git a/Dockerfile b/Dockerfile index 8bf23ab0..ec3e3b25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -413,6 +413,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/nbqa/bin" ENV PATH="${PATH}:/venvs/pyink/bin" ENV PATH="${PATH}:/venvs/pylint/bin" ENV PATH="${PATH}:/venvs/ruff/bin" diff --git a/README.md b/README.md index d4bc2db2..9da55e75 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ Super-linter supports the following tools: | **JSON** | [eslint-plugin-jsonc (configured for JSON)](https://www.npmjs.com/package/eslint-plugin-jsonc) (default), [eslint-plugin-json](https://www.npmjs.com/package/eslint-plugin-json) | [Prettier](https://prettier.io/) | | **JSONC**, **JSON5** | [eslint-plugin-jsonc](https://www.npmjs.com/package/eslint-plugin-jsonc) | [Prettier](https://prettier.io/) | | **JSX**, **TSX** | [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y), [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) | [Prettier](https://prettier.io/) | +| **Jupyter Notebook** | [nbqa](https://nbqa.readthedocs.io/en/latest/index.html) | [nbqa](https://nbqa.readthedocs.io/en/latest/index.html) | | **Kubernetes** | [kubeconform](https://github.com/yannh/kubeconform), [Checkov](https://www.checkov.io/) | See YAML formatters | | **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | | | **LaTeX** | [ChkTex](https://www.nongnu.org/chktex/) | | @@ -249,6 +250,9 @@ You can configure Super-linter using the following environment variables: | **FIX_JSONC_PRETTIER** | `true` | Flag to enable or disable the formatting of JSONC and JSON5 files with Prettier. | | **FIX_JSX_PRETTIER** | `true` | Flag to enable or disable the formatting of JSX files with Prettier. | | **FIX_JSX** | `false` | Option to enable fix mode for `JSX`. | +| **FIX_JUPYTER_NBQA_BLACK** | `false` | Option to enable fix mode for `NBQA_BLACK`. | +| **FIX_JUPYTER_NBQA_ISORT** | `false` | Option to enable fix mode for `NBQA_ISORT`. | +| **FIX_JUPYTER_NBQA_RUFF** | `false` | Option to enable fix mode for `NBQA_RUFF`. | | **FIX_MARKDOWN_PRETTIER** | `true` | Flag to enable or disable the formatting of Markdown files with Prettier. | | **FIX_MARKDOWN** | `false` | Option to enable fix mode for `MARKDOWN`. | | **FIX_POWERSHELL** | `false` | Option to enable fix mode for `POWERSHELL`. | @@ -285,6 +289,7 @@ You can configure Super-linter using the following environment variables: | **JAVA_FILE_NAME** | `sun_checks.xml` | Filename for [Checkstyle configuration](https://checkstyle.sourceforge.io/config.html). Checkstyle embeds several configuration files, such as `sun_checks.xml`, `google_checks.xml` that you can use without providing your own configuration file. | | **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [ESLint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`) | | **JSCPD_CONFIG_FILE** | `.jscpd.json` | Filename for JSCPD configuration | +| **JUPYTER_NBQA_CONFIG_FILE** | `.jupyter-nbqa.toml` | Filename for [nbqa configuration](https://nbqa.readthedocs.io/en/latest/configuration.html) | | **KUBERNETES_KUBECONFORM_OPTIONS** | `null` | Additional arguments to pass to the command-line when running **Kubernetes Kubeconform** (Example: --ignore-missing-schemas) | | **LINTER_RULES_PATH** | `.github/linters` | Directory for all linter configuration rules. | | **LOG_FILE** | `super-linter.log` | The filename for outputting logs. Super-linter saves the log file to `${DEFAULT_WORKSPACE}/${LOG_FILE}`. | @@ -373,6 +378,12 @@ You can configure Super-linter using the following environment variables: | **VALIDATE_JSONC_PRETTIER** | `true` | Flag to enable or disable checking the formatting of JSONC and JSON5 files with Prettier. | | **VALIDATE_JSX** | `true` | Flag to enable or disable the linting process for jsx files (Utilizing: ESLint) | | **VALIDATE_JSX_PRETTIER** | `true` | Flag to enable or disable checking the formatting of JSX files with Prettier. | +| **VALIDATE_JUPYTER_NBQA_BLACK** | `true` | Flag to enable or disable the linting process of Jupyter Notebooks. (Utilizing: nbqa black) | +| **VALIDATE_JUPYTER_NBQA_FLAKE8** | `true` | Flag to enable or disable the linting process of Jupyter Notebooks. (Utilizing: nbqa flake8) | +| **VALIDATE_JUPYTER_NBQA_ISORT** | `true` | Flag to enable or disable the linting process of Jupyter Notebooks. (Utilizing: nbqa isort) | +| **VALIDATE_JUPYTER_NBQA_MYPY** | `true` | Flag to enable or disable the linting process of Jupyter Notebooks. (Utilizing: nbqa mypy) | +| **VALIDATE_JUPYTER_NBQA_PYLINT** | `true` | Flag to enable or disable the linting process of Jupyter Notebooks. (Utilizing: nbqa pylint) | +| **VALIDATE_JUPYTER_NBQA_RUFF** | `true` | Flag to enable or disable the linting process of Jupyter Notebooks. (Utilizing: nbqa ruff) | | **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the Kotlin language. | | **VALIDATE_KUBERNETES_KUBECONFORM** | `true` | Flag to enable or disable the linting process of Kubernetes descriptors with Kubeconform | | **VALIDATE_LATEX** | `true` | Flag to enable or disable the linting process of the LaTeX language. | diff --git a/TEMPLATES/.jupyter-nbqa.toml b/TEMPLATES/.jupyter-nbqa.toml new file mode 100644 index 00000000..e69de29b diff --git a/dependencies/python/nbqa.txt b/dependencies/python/nbqa.txt new file mode 100644 index 00000000..a3faa232 --- /dev/null +++ b/dependencies/python/nbqa.txt @@ -0,0 +1 @@ +nbqa==1.9.0 diff --git a/docs/add-new-linter.md b/docs/add-new-linter.md index b1491b51..617abfdd 100644 --- a/docs/add-new-linter.md +++ b/docs/add-new-linter.md @@ -20,8 +20,8 @@ tool, do the following. violations that the fix mode can automatically fix. Avoid test cases that fail only because of syntax errors, when possible. 4. Update expected summary reports: `test/data/super-linter-summary`. -5. If the tool supports check-only mode or fix mode, add the `` to - the `LANGUAGES_WITH_FIX_MODE` array in `test/testUtils.sh` +5. If the tool supports check-only mode or fix mode, add the `` to the + `LANGUAGES_WITH_FIX_MODE` array in `test/testUtils.sh` ## Update the test suite diff --git a/lib/functions/buildFileList.sh b/lib/functions/buildFileList.sh index 6b4a9b3f..df03bdb4 100755 --- a/lib/functions/buildFileList.sh +++ b/lib/functions/buildFileList.sh @@ -457,6 +457,13 @@ BuildFileArrays() { elif [ "${FILE_TYPE}" == "jsx" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSX" echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSX_PRETTIER" + elif [ "${FILE_TYPE}" == "ipynb" ]; then + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JUPYTER_NBQA_BLACK" + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JUPYTER_NBQA_FLAKE8" + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JUPYTER_NBQA_ISORT" + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JUPYTER_NBQA_MYPY" + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JUPYTER_NBQA_PYLINT" + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JUPYTER_NBQA_RUFF" elif [ "${FILE_TYPE}" == "kt" ] || [ "${FILE_TYPE}" == "kts" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-KOTLIN" elif [ "$FILE_TYPE" == "lua" ]; then diff --git a/lib/functions/linterCommands.sh b/lib/functions/linterCommands.sh index e018632e..1513cedd 100755 --- a/lib/functions/linterCommands.sh +++ b/lib/functions/linterCommands.sh @@ -187,6 +187,12 @@ LINTER_COMMANDS_ARRAY_JSONC=(eslint -c "${JAVASCRIPT_ES_LINTER_RULES}" --ext '.j LINTER_COMMANDS_ARRAY_JSONC_PRETTIER=("${PRETTIER_COMMAND[@]}") LINTER_COMMANDS_ARRAY_JSX=(eslint -c "${JSX_LINTER_RULES}") LINTER_COMMANDS_ARRAY_JSX_PRETTIER=("${PRETTIER_COMMAND[@]}") +LINTER_COMMANDS_ARRAY_JUPYTER_NBQA_BLACK=(nbqa black --nbqa-shell) +LINTER_COMMANDS_ARRAY_JUPYTER_NBQA_FLAKE8=(nbqa flake8 --nbqa-shell) +LINTER_COMMANDS_ARRAY_JUPYTER_NBQA_ISORT=(nbqa isort --nbqa-shell) +LINTER_COMMANDS_ARRAY_JUPYTER_NBQA_MYPY=(nbqa mypy --nbqa-shell) +LINTER_COMMANDS_ARRAY_JUPYTER_NBQA_PYLINT=(nbqa pylint --nbqa-shell) +LINTER_COMMANDS_ARRAY_JUPYTER_NBQA_RUFF=(nbqa ruff --nbqa-shell) LINTER_COMMANDS_ARRAY_KOTLIN=(ktlint "{/}") LINTER_COMMANDS_ARRAY_KUBERNETES_KUBECONFORM=(kubeconform -strict) if [ "${KUBERNETES_KUBECONFORM_OPTIONS}" != "null" ] && [ -n "${KUBERNETES_KUBECONFORM_OPTIONS}" ]; then diff --git a/lib/globals/languages.sh b/lib/globals/languages.sh index a0d672cb..08719398 100755 --- a/lib/globals/languages.sh +++ b/lib/globals/languages.sh @@ -28,6 +28,12 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CHECKOV' 'CLANG_FORMAT' "JSONC_PRETTIER" 'JSX' "JSX_PRETTIER" + "JUPYTER_NBQA_BLACK" + "JUPYTER_NBQA_FLAKE8" + "JUPYTER_NBQA_ISORT" + "JUPYTER_NBQA_MYPY" + "JUPYTER_NBQA_PYLINT" + "JUPYTER_NBQA_RUFF" 'KUBERNETES_KUBECONFORM' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN' "MARKDOWN_PRETTIER" 'NATURAL_LANGUAGE' 'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN' diff --git a/lib/globals/linterCommandsOptions.sh b/lib/globals/linterCommandsOptions.sh index 1301a00b..21b96e94 100755 --- a/lib/globals/linterCommandsOptions.sh +++ b/lib/globals/linterCommandsOptions.sh @@ -24,6 +24,8 @@ JAVASCRIPT_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS JSON_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") JSONC_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") JSX_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") +JUPYTER_NBQA_BLACK_CHECK_ONLY_MODE_OPTIONS=(--diff --check) +JUPYTER_NBQA_ISORT_CHECK_ONLY_MODE_OPTIONS=(--diff --check) 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) @@ -68,6 +70,7 @@ JSONC_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}") JSONC_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}") JSX_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}") JSX_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}") +JUPYTER_NBQA_RUFF_FIX_MODE_OPTIONS=(--fix) MARKDOWN_FIX_MODE_OPTIONS=(--fix) MARKDOWN_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}") NATURAL_LANGUAGE_FIX_MODE_OPTIONS=(--fix) diff --git a/lib/globals/linterRules.sh b/lib/globals/linterRules.sh index 2aee44ae..27cb81c1 100755 --- a/lib/globals/linterRules.sh +++ b/lib/globals/linterRules.sh @@ -54,6 +54,8 @@ MARKDOWN_CUSTOM_RULE_GLOBS="${MARKDOWN_CUSTOM_RULE_GLOBS:-""}" # shellcheck disable=SC2034 # Variable is referenced indirectly MARKDOWN_FILE_NAME="${MARKDOWN_CONFIG_FILE:-.markdown-lint.yml}" # shellcheck disable=SC2034 # Variable is referenced indirectly +JUPYTER_NBQA_FILE_NAME="${JUPYTER_NBQA_CONFIG_FILE:-.jupyter-nbqa.toml}" +# shellcheck disable=SC2034 # Variable is referenced indirectly OPENAPI_FILE_NAME=".openapirc.yml" # shellcheck disable=SC2034 # Variable is referenced indirectly PERL_PERLCRITIC_OPTIONS="${PERL_PERLCRITIC_OPTIONS:-null}" diff --git a/lib/linter.sh b/lib/linter.sh index aea07be6..9f78dfce 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -632,7 +632,8 @@ cleanup() { debug "Removing temporary files and directories" rm -rf \ "${GITHUB_WORKSPACE}/.mypy_cache" \ - "${GITHUB_WORKSPACE}/logback.log" + "${GITHUB_WORKSPACE}/logback.log" \ + "${GITHUB_WORKSPACE}/.ruff_cache" if [[ "${SUPER_LINTER_COPIED_R_LINTER_RULES_FILE:-}" == "true" ]]; then debug "Deleting ${R_RULES_FILE_PATH_IN_ROOT} because super-linter created it." diff --git a/scripts/linterVersions.sh b/scripts/linterVersions.sh index db599f9d..eb97d81f 100755 --- a/scripts/linterVersions.sh +++ b/scripts/linterVersions.sh @@ -47,6 +47,12 @@ LINTER_NAMES_ARRAY['JSONC']="eslint" LINTER_NAMES_ARRAY['JSONC_PRETTIER']="prettier" LINTER_NAMES_ARRAY['JSX']="eslint" LINTER_NAMES_ARRAY['JSX_PRETTIER']="prettier" +LINTER_NAMES_ARRAY['JUPYTER_NBQA_BLACK']="nbqa" +LINTER_NAMES_ARRAY['JUPYTER_NBQA_FLAKE8']="nbqa" +LINTER_NAMES_ARRAY['JUPYTER_NBQA_ISORT']="nbqa" +LINTER_NAMES_ARRAY['JUPYTER_NBQA_MYPY']="nbqa" +LINTER_NAMES_ARRAY['JUPYTER_NBQA_PYLINT']="nbqa" +LINTER_NAMES_ARRAY['JUPYTER_NBQA_RUFF']="nbqa" LINTER_NAMES_ARRAY['KOTLIN']="ktlint" LINTER_NAMES_ARRAY['KUBERNETES_KUBECONFORM']="kubeconform" LINTER_NAMES_ARRAY['LATEX']="chktex" @@ -231,7 +237,7 @@ for LANGUAGE in "${!LINTER_NAMES_ARRAY[@]}"; do elif [[ "${LINTER}" == "yamllint" ]]; then GET_VERSION_CMD="$("${LINTER}" --version | awk '{ print $2 }')" # Some linters don't support a "get version" command - elif [[ ${LINTER} == "bash-exec" ]] || [[ ${LINTER} == "gherkin-lint" ]]; then + elif [[ ${LINTER} == "bash-exec" ]] || [[ ${LINTER} == "nbqa" ]] || [[ ${LINTER} == "gherkin-lint" ]]; then GET_VERSION_CMD="Version command not supported" else GET_VERSION_CMD="$("${LINTER}" --version 2>&1)" diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-slim.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-slim.md index dc6ce1bf..4450f1d8 100644 --- a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-slim.md +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-slim.md @@ -43,6 +43,12 @@ | JSONC_PRETTIER | Fail ❌ | | JSX | Fail ❌ | | JSX_PRETTIER | Fail ❌ | +| JUPYTER_NBQA_BLACK | Fail ❌ | +| JUPYTER_NBQA_FLAKE8 | Fail ❌ | +| JUPYTER_NBQA_ISORT | Fail ❌ | +| JUPYTER_NBQA_MYPY | Fail ❌ | +| JUPYTER_NBQA_PYLINT | Fail ❌ | +| JUPYTER_NBQA_RUFF | Fail ❌ | | KUBERNETES_KUBECONFORM | Fail ❌ | | KOTLIN | Fail ❌ | | LATEX | Fail ❌ | diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-standard.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-standard.md index cad30a61..39b22441 100644 --- a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-standard.md +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-standard.md @@ -48,6 +48,12 @@ | JSONC_PRETTIER | Fail ❌ | | JSX | Fail ❌ | | JSX_PRETTIER | Fail ❌ | +| JUPYTER_NBQA_BLACK | Fail ❌ | +| JUPYTER_NBQA_FLAKE8 | Fail ❌ | +| JUPYTER_NBQA_ISORT | Fail ❌ | +| JUPYTER_NBQA_MYPY | Fail ❌ | +| JUPYTER_NBQA_PYLINT | Fail ❌ | +| JUPYTER_NBQA_RUFF | Fail ❌ | | KUBERNETES_KUBECONFORM | Fail ❌ | | KOTLIN | Fail ❌ | | LATEX | Fail ❌ | diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-slim.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-slim.md index f72663bd..0c632cfd 100644 --- a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-slim.md +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-slim.md @@ -43,6 +43,12 @@ | JSONC_PRETTIER | Pass ✅ | | JSX | Pass ✅ | | JSX_PRETTIER | Pass ✅ | +| JUPYTER_NBQA_BLACK | Pass ✅ | +| JUPYTER_NBQA_FLAKE8 | Pass ✅ | +| JUPYTER_NBQA_ISORT | Pass ✅ | +| JUPYTER_NBQA_MYPY | Pass ✅ | +| JUPYTER_NBQA_PYLINT | Pass ✅ | +| JUPYTER_NBQA_RUFF | Pass ✅ | | KUBERNETES_KUBECONFORM | Pass ✅ | | KOTLIN | Pass ✅ | | LATEX | Pass ✅ | diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-standard.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-standard.md index 9dbb00b0..2fc9a88f 100644 --- a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-standard.md +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-standard.md @@ -48,6 +48,12 @@ | JSONC_PRETTIER | Pass ✅ | | JSX | Pass ✅ | | JSX_PRETTIER | Pass ✅ | +| JUPYTER_NBQA_BLACK | Pass ✅ | +| JUPYTER_NBQA_FLAKE8 | Pass ✅ | +| JUPYTER_NBQA_ISORT | Pass ✅ | +| JUPYTER_NBQA_MYPY | Pass ✅ | +| JUPYTER_NBQA_PYLINT | Pass ✅ | +| JUPYTER_NBQA_RUFF | Pass ✅ | | KUBERNETES_KUBECONFORM | Pass ✅ | | KOTLIN | Pass ✅ | | LATEX | Pass ✅ | diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-slim.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-slim.md index 9ab0be6f..c9fbad3b 100644 --- a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-slim.md +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-slim.md @@ -24,6 +24,9 @@ | JSONC_PRETTIER | Pass ✅ | | JSX | Fail ❌ | | JSX_PRETTIER | Pass ✅ | +| JUPYTER_NBQA_BLACK | Pass ✅ | +| JUPYTER_NBQA_ISORT | Pass ✅ | +| JUPYTER_NBQA_RUFF | Pass ✅ | | MARKDOWN | Pass ✅ | | MARKDOWN_PRETTIER | Pass ✅ | | NATURAL_LANGUAGE | Pass ✅ | diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-standard.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-standard.md index 3583eabf..303dedc2 100644 --- a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-standard.md +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-standard.md @@ -28,6 +28,9 @@ | JSONC_PRETTIER | Pass ✅ | | JSX | Fail ❌ | | JSX_PRETTIER | Pass ✅ | +| JUPYTER_NBQA_BLACK | Pass ✅ | +| JUPYTER_NBQA_ISORT | Pass ✅ | +| JUPYTER_NBQA_RUFF | Pass ✅ | | MARKDOWN | Pass ✅ | | MARKDOWN_PRETTIER | Pass ✅ | | NATURAL_LANGUAGE | Pass ✅ | diff --git a/test/inspec/super-linter/controls/super_linter.rb b/test/inspec/super-linter/controls/super_linter.rb index 52f10989..d5441531 100644 --- a/test/inspec/super-linter/controls/super_linter.rb +++ b/test/inspec/super-linter/controls/super_linter.rb @@ -185,6 +185,7 @@ control "super-linter-installed-commands" do { linter_name: "lua", version_option: "-v"}, { linter_name: "markdownlint"}, { linter_name: "mypy"}, + { linter_name: "nbqa"}, { linter_name: "npm-groovy-lint"}, { linter_name: "perl"}, { linter_name: "php"}, @@ -415,6 +416,7 @@ control "super-linter-installed-pypi-packages" do "flake8", "isort", "mypy", + "nbqa", "pyink", "pylint", "ruff", @@ -517,6 +519,7 @@ control "super-linter-validate-files" do "/action/lib/.automation/.luacheckrc", "/action/lib/.automation/.markdown-lint.yml", "/action/lib/.automation/.mypy.ini", + "/action/lib/.automation/.jupyter-nbqa.toml", "/action/lib/.automation/.openapirc.yml", "/action/lib/.automation/.perlcriticrc", "/action/lib/.automation/.powershell-psscriptanalyzer.psd1", diff --git a/test/linters/jupyter_nbqa_black/jupyter_bad_1.ipynb b/test/linters/jupyter_nbqa_black/jupyter_bad_1.ipynb new file mode 100644 index 00000000..8260e312 --- /dev/null +++ b/test/linters/jupyter_nbqa_black/jupyter_bad_1.ipynb @@ -0,0 +1,32 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "hHETjoFLGZmM" + }, + "outputs": [], + "source": [ + "a=1;b=2\n", + "c=a+b\n", + "BROKEN_VAR=BROKEN_VAR\n", + "print(c)" + ] + } + ] +} diff --git a/test/linters/jupyter_nbqa_black/jupyter_good_1.ipynb b/test/linters/jupyter_nbqa_black/jupyter_good_1.ipynb new file mode 100644 index 00000000..b75828cd --- /dev/null +++ b/test/linters/jupyter_nbqa_black/jupyter_good_1.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "hHETjoFLGZmM" + }, + "outputs": [], + "source": [ + "a = 1\n", + "b = 2\n", + "c = a + b\n", + "print(c)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/test/linters/jupyter_nbqa_flake8/jupyter_bad_1.ipynb b/test/linters/jupyter_nbqa_flake8/jupyter_bad_1.ipynb new file mode 100644 index 00000000..23ae443d --- /dev/null +++ b/test/linters/jupyter_nbqa_flake8/jupyter_bad_1.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "hHETjoFLGZmM" + }, + "outputs": [], + "source": [ + "a=1;b=2\n", + "c=a+b\n", + "BROKEN_VAR=BROKEN_VAR\n", + "print(c)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/test/linters/jupyter_nbqa_flake8/jupyter_good_1.ipynb b/test/linters/jupyter_nbqa_flake8/jupyter_good_1.ipynb new file mode 100644 index 00000000..b75828cd --- /dev/null +++ b/test/linters/jupyter_nbqa_flake8/jupyter_good_1.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "hHETjoFLGZmM" + }, + "outputs": [], + "source": [ + "a = 1\n", + "b = 2\n", + "c = a + b\n", + "print(c)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/test/linters/jupyter_nbqa_isort/jupyter_bad_1.ipynb b/test/linters/jupyter_nbqa_isort/jupyter_bad_1.ipynb new file mode 100644 index 00000000..789a7236 --- /dev/null +++ b/test/linters/jupyter_nbqa_isort/jupyter_bad_1.ipynb @@ -0,0 +1,38 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "hHETjoFLGZmM" + }, + "outputs": [], + "source": [ + "import json\n", + "from os import getenv, path\n", + "from pprint import pprint\n", + "import sys\n", + "\n", + "\n", + "a=1;b=2\n", + "c=a+b\n", + "BROKEN_VAR=BROKEN_VAR\n", + "print(c)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/test/linters/jupyter_nbqa_isort/jupyter_good_1.ipynb b/test/linters/jupyter_nbqa_isort/jupyter_good_1.ipynb new file mode 100644 index 00000000..b75828cd --- /dev/null +++ b/test/linters/jupyter_nbqa_isort/jupyter_good_1.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "hHETjoFLGZmM" + }, + "outputs": [], + "source": [ + "a = 1\n", + "b = 2\n", + "c = a + b\n", + "print(c)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/test/linters/jupyter_nbqa_mypy/nbqa_bad_1.ipynb b/test/linters/jupyter_nbqa_mypy/nbqa_bad_1.ipynb new file mode 100644 index 00000000..23ae443d --- /dev/null +++ b/test/linters/jupyter_nbqa_mypy/nbqa_bad_1.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "hHETjoFLGZmM" + }, + "outputs": [], + "source": [ + "a=1;b=2\n", + "c=a+b\n", + "BROKEN_VAR=BROKEN_VAR\n", + "print(c)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/test/linters/jupyter_nbqa_mypy/nbqa_good_1.ipynb b/test/linters/jupyter_nbqa_mypy/nbqa_good_1.ipynb new file mode 100644 index 00000000..b75828cd --- /dev/null +++ b/test/linters/jupyter_nbqa_mypy/nbqa_good_1.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "hHETjoFLGZmM" + }, + "outputs": [], + "source": [ + "a = 1\n", + "b = 2\n", + "c = a + b\n", + "print(c)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/test/linters/jupyter_nbqa_pylint/jupyter_bad_1.ipynb b/test/linters/jupyter_nbqa_pylint/jupyter_bad_1.ipynb new file mode 100644 index 00000000..23ae443d --- /dev/null +++ b/test/linters/jupyter_nbqa_pylint/jupyter_bad_1.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "hHETjoFLGZmM" + }, + "outputs": [], + "source": [ + "a=1;b=2\n", + "c=a+b\n", + "BROKEN_VAR=BROKEN_VAR\n", + "print(c)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/test/linters/jupyter_nbqa_pylint/jupyter_good_1.ipynb b/test/linters/jupyter_nbqa_pylint/jupyter_good_1.ipynb new file mode 100644 index 00000000..9c42765a --- /dev/null +++ b/test/linters/jupyter_nbqa_pylint/jupyter_good_1.ipynb @@ -0,0 +1,34 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "hHETjoFLGZmM" + }, + "outputs": [], + "source": [ + "\"\"\"Test Python file for Pylint.\"\"\"\n", + "\n", + "A = 1\n", + "B = 2\n", + "C = A + B\n", + "print(C)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/test/linters/jupyter_nbqa_ruff/jupyter_bad_1.ipynb b/test/linters/jupyter_nbqa_ruff/jupyter_bad_1.ipynb new file mode 100644 index 00000000..36f0c63d --- /dev/null +++ b/test/linters/jupyter_nbqa_ruff/jupyter_bad_1.ipynb @@ -0,0 +1,33 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "hHETjoFLGZmM" + }, + "outputs": [], + "source": [ + "import pandas\n", + "import numpy as np\n", + "\n", + "c = 1 + 2\n", + "print(c)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/test/linters/jupyter_nbqa_ruff/jupyter_good_1.ipynb b/test/linters/jupyter_nbqa_ruff/jupyter_good_1.ipynb new file mode 100644 index 00000000..b75828cd --- /dev/null +++ b/test/linters/jupyter_nbqa_ruff/jupyter_good_1.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "hHETjoFLGZmM" + }, + "outputs": [], + "source": [ + "a = 1\n", + "b = 2\n", + "c = a + b\n", + "print(c)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/test/testUtils.sh b/test/testUtils.sh index a5faa6e0..372bee7f 100755 --- a/test/testUtils.sh +++ b/test/testUtils.sh @@ -53,6 +53,9 @@ LANGUAGES_WITH_FIX_MODE=( "JSONC_PRETTIER" "JSX" "JSX_PRETTIER" + "JUPYTER_NBQA_BLACK" + "JUPYTER_NBQA_ISORT" + "JUPYTER_NBQA_RUFF" "MARKDOWN" "MARKDOWN_PRETTIER" "NATURAL_LANGUAGE"