From c1529c430fb6bde3a8854db010326ef16b4e18c9 Mon Sep 17 00:00:00 2001 From: Craig Callender <125502786+CraigCallender@users.noreply.github.com> Date: Fri, 19 Sep 2025 15:48:26 +0000 Subject: [PATCH 1/5] Adding supported filetypes .pyi and .ipynb to ruff and ruff-format linters. --- megalinter/descriptors/python.megalinter-descriptor.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/megalinter/descriptors/python.megalinter-descriptor.yml b/megalinter/descriptors/python.megalinter-descriptor.yml index 745a5dbc0f1..3f4a6f336af 100644 --- a/megalinter/descriptors/python.megalinter-descriptor.yml +++ b/megalinter/descriptors/python.megalinter-descriptor.yml @@ -517,6 +517,10 @@ linters: - linter_name: ruff name: PYTHON_RUFF can_output_sarif: true + file_extensions: + - ".py" + - ".pyi" + - ".ipynb" linter_text: | **Ruff** is an extremely fast Python linter and code formatter written in Rust that aims to be 10-100x faster than existing tools while providing comprehensive functionality behind a single interface. @@ -575,6 +579,10 @@ linters: class: RuffFormatLinter name: PYTHON_RUFF_FORMAT is_formatter: true + file_extensions: + - ".py" + - ".pyi" + - ".ipynb" activation_rules: - type: variable variable: PYTHON_DEFAULT_STYLE From ace23fd2aa1338f7cafbb53ce00e0f0fcf03ed5e Mon Sep 17 00:00:00 2001 From: Craig Callender <125502786+CraigCallender@users.noreply.github.com> Date: Fri, 19 Sep 2025 15:54:16 +0000 Subject: [PATCH 2/5] Adding change log. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 478b793e760..c991ba230c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l - Fixes - When linter is docker based, force `--platform=linux/amd64` so it works when running locally on Mac + - Added checking of `*.pyi` and `*.ipynb` files to the `ruff` and `ruff-format` linters - Reporters - New default display for Pull Request comments, with expandable sections containing the first 1000 lines of the output log. Former display remains available by defining `REPORTERS_MARKDOWN_SUMMARY_TYPE=table` From 051ea84e3e698b4b2d74e70468d32497a36f5d06 Mon Sep 17 00:00:00 2001 From: Craig Callender <125502786+CraigCallender@users.noreply.github.com> Date: Fri, 19 Sep 2025 16:05:41 +0000 Subject: [PATCH 3/5] Adding ipynb to cspell library --- .cspell.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.cspell.json b/.cspell.json index 7382b0faa7e..40be2d37595 100644 --- a/.cspell.json +++ b/.cspell.json @@ -115,6 +115,7 @@ "imple", "iname", "inimal", + "ipynb", "is-arrayish", "isaacs", "johnnymorganz", From 23267259621a753c9746ae6fb6ae52fbd1a57af8 Mon Sep 17 00:00:00 2001 From: Craig Callender <125502786+CraigCallender@users.noreply.github.com> Date: Tue, 23 Sep 2025 07:15:32 +0000 Subject: [PATCH 4/5] Expanding support for different python filetypes to black, bandit, mypy, pylint, isort, and pyright. --- .../python.megalinter-descriptor.yml | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/megalinter/descriptors/python.megalinter-descriptor.yml b/megalinter/descriptors/python.megalinter-descriptor.yml index 3f4a6f336af..43dedd124f8 100644 --- a/megalinter/descriptors/python.megalinter-descriptor.yml +++ b/megalinter/descriptors/python.megalinter-descriptor.yml @@ -10,6 +10,9 @@ processing_order: -9 linters: # PYLINT - linter_name: pylint + file_extensions: + - ".py" + - ".pyi" linter_text: | **Pylint** is a comprehensive static code analyzer for Python that goes beyond simple syntax checking. It analyzes your code without actually running it, checking for errors, enforcing coding standards, detecting code smells, and suggesting refactoring opportunities. @@ -85,6 +88,10 @@ linters: url: https://code.visualstudio.com/docs/python/linting#_pylint # BLACK - linter_name: black + file_extensions: + - ".py" + - ".pyi" + - ".ipynb" linter_text: | **Black** is "the uncompromising code formatter" for Python that automatically formats your code to be consistent and PEP 8 compliant. By using Black, you agree to cede control over minutiae of hand-formatting in return for speed, determinism, and freedom from formatting debates. @@ -153,7 +160,7 @@ linters: # renovate: datasource=pypi depName=black ARG PIP_BLACK_VERSION=25.9.0 pip: - - black==${PIP_BLACK_VERSION} + - black[jupyter]==${PIP_BLACK_VERSION} ide: emacs: - name: blacken @@ -218,6 +225,11 @@ linters: url: https://code.visualstudio.com/docs/python/linting#_flake8 # ISORT - linter_name: isort + file_extensions: + - ".py" + - ".pyi" + - ".pyx" + - ".pxd" linter_text: | **isort** is the definitive Python import sorting tool that automatically organizes and standardizes import statements according to configurable rules. It serves as an essential companion to code formatters for maintaining clean, professional Python codebases. @@ -286,6 +298,10 @@ linters: - linter_name: bandit name: PYTHON_BANDIT can_output_sarif: true + file_extensions: + - ".py" + - ".pyi" + - ".ipynb" descriptor_flavors: - python - security @@ -366,6 +382,10 @@ linters: # MYPY - linter_name: mypy name: PYTHON_MYPY + file_extensions: + - ".py" + - ".pyi" + - ".ipynb" linter_text: | **MyPy** is Python's premier static type checker that brings optional static typing to Python through gradual typing. It analyzes type annotations and infers types to catch bugs before runtime, bridging the gap between Python's dynamic nature and static analysis benefits. @@ -459,6 +479,9 @@ linters: - class: PyrightLinter linter_name: pyright name: PYTHON_PYRIGHT + file_extensions: + - ".py" + - ".pyi" linter_text: | **Pyright** is Microsoft's high-performance static type checker for Python that provides fast, accurate type analysis. It serves as a powerful alternative to MyPy with focus on speed and developer experience. From 81927c7ec7e384aeb130ddd41a2714de56f0cef5 Mon Sep 17 00:00:00 2001 From: Craig Callender <125502786+CraigCallender@users.noreply.github.com> Date: Tue, 23 Sep 2025 07:23:42 +0000 Subject: [PATCH 5/5] Updating changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f501e24e1e2..af9849d23b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l - Media - Linters enhancements + - Python Linting: Added more file type supports for various linters. Full description [here](https://github.com/oxsecurity/megalinter/pull/6214) - Fixes