Skip to content

fix: Enable PYTHON_NBQA_MYPY linter by removing disabled flag#7209

Merged
nvuillam merged 3 commits intooxsecurity:mainfrom
yousfiSaad:fix/nbqa-mypy-test-classes
Feb 23, 2026
Merged

fix: Enable PYTHON_NBQA_MYPY linter by removing disabled flag#7209
nvuillam merged 3 commits intooxsecurity:mainfrom
yousfiSaad:fix/nbqa-mypy-test-classes

Conversation

@yousfiSaad
Copy link
Contributor

@yousfiSaad yousfiSaad commented Feb 23, 2026

Summary

  • Remove disabled: true from PYTHON_NBQA_MYPY descriptor
  • Remove disabled_reason that was added as a temporary fix
  • Regenerate build artifacts via make megalinter-build

Problem

Follow-up to #7016 - maintainer disabled the linter because test classes were failing.

Solution

The test class (python_nbqa_mypy_test.py) and test folder (.automation/test/python_nbqa_mypy/) already exist in the codebase. This PR simply re-enables the linter by removing the disabled flag.

Changes

  • megalinter/descriptors/python.megalinter-descriptor.yml: Remove disabled: true and disabled_reason
  • Build artifacts regenerated (Dockerfile, flavor files, etc.)

Related

Co-Authored-By: Claude noreply@anthropic.com


Edit: Root Cause Clarification

After further investigation, the actual root cause of the test failures was not the test classes themselves.

What Really Happened

The bug was in the descriptor configuration:

cli_config_arg_name: "--config-file"
config_file_name: ".mypy.ini"

This configuration caused MegaLinter to build the command:

nbqa mypy --install-types --non-interactive --config-file /path/.mypy.ini notebook.ipynb

The Problem: --config-file was being passed to nbqa (which doesn't recognize it), instead of being passed through to mypy.

The actual error was:

mypy: error: argument --config-file: expected one argument

The Fix

Commit faf9911307 removed cli_config_arg_name and config_file_name from the descriptor. The command now correctly builds as:

nbqa mypy --install-types --non-interactive notebook.ipynb

MyPy auto-detects config files (pyproject.toml, .mypy.ini, setup.cfg, etc.) in the project directory.

The test classes were never broken - it was a configuration issue all along.


Note

Medium Risk
Enables an additional linter and adds nbqa to the container images, which can change CI behavior (new failures/time) and slightly increases image/build complexity.

Overview
Re-enables the PYTHON_NBQA_MYPY linter for Jupyter notebooks by removing its disabled state and adjusting the descriptor to rely on mypy’s auto-discovered config (instead of passing a --config-file flag through nbqa).

Regenerates build artifacts to include python_nbqa_mypy in the linter matrix and flavors, and updates the base/flavor Dockerfiles to install nbqa (new /venvs/nbqa plus PATH wiring) so the linter is available at runtime.

Written by Cursor Bugbot for commit 88b744e. This will update automatically on new commits. Configure here.

- Remove `disabled: true` from PYTHON_NBQA_MYPY descriptor
- Remove `disabled_reason` that was added as a temporary fix
- Regenerate build artifacts via `make megalinter-build`

The test class and test folder already exist in the codebase.
This enables the linter that was disabled due to test issues.

Fixes issue flagged by maintainer in PR oxsecurity#7016

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@echoix
Copy link
Collaborator

echoix commented Feb 23, 2026

And how are the test classes fixed now?

The config argument was being passed to nbqa instead of mypy:
- nbqa --config-file /path/.mypy.ini mypy ...  (WRONG)
- nbqa mypy --config-file /path/.mypy.ini ... (CORRECT)

Since MegaLinter places cli_config_arg_name before the linter name,
we need to remove it and rely on mypy's auto-detection of config files.

MyPy automatically detects: pyproject.toml, .mypy.ini, setup.cfg

Fixes test failures in CI.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@yousfiSaad
Copy link
Contributor Author

@echoix Good question! Let me clarify:

The test class already existed - it was generated when the original PR (#7016) was merged.

The real issue was a configuration bug that caused the tests to fail:

Root Cause

The descriptor had:

cli_config_arg_name: "--config-file"
config_file_name: ".mypy.ini"

This caused MegaLinter to build the command like:

nbqa mypy --install-types --non-interactive --config-file /path/.mypy.ini notebook.ipynb

The problem: --config-file was being passed to nbqa (which doesn't recognize it), not to mypy.

The error was:

mypy: error: argument --config-file: expected one argument

The Fix

Removed cli_config_arg_name and config_file_name from the descriptor. Now the command is:

nbqa mypy --install-types --non-interactive notebook.ipynb

MyPy will auto-detect config files (pyproject.toml, .mypy.ini, setup.cfg) in the project directory.

CI is running now to verify the fix.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on March 6

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

cli_config_arg_name: "--config-file"
config_file_name: ".mypy.ini"
# Note: nbqa passes args to the underlying tool (mypy), so we don't use cli_config_arg_name
# MyPy will auto-detect config files (pyproject.toml, .mypy.ini, setup.cfg, etc.)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed cli_config_arg_name falls back to wrong default

Medium Severity

Removing cli_config_arg_name: "--config-file" causes it to fall back to the Linter.py default of "-c". If a user sets PYTHON_NBQA_MYPY_CONFIG_FILE or PYTHON_CONFIG_FILE env vars, the linter will pass -c <config> to nbqa/mypy instead of --config-file <config>. For mypy, -c means "type-check a program passed as string," which is completely wrong for config file passing. The fix is to either keep cli_config_arg_name: "--config-file" (removing only config_file_name) or explicitly set cli_config_arg_name: "" like the cljstyle linter does to prevent any config arg from being passed.

Fix in Cursor Fix in Web

Copy link
Member

@nvuillam nvuillam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, thanks for the updates :)

@nvuillam nvuillam merged commit 64535f3 into oxsecurity:main Feb 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants