fix: Enable PYTHON_NBQA_MYPY linter by removing disabled flag#7209
fix: Enable PYTHON_NBQA_MYPY linter by removing disabled flag#7209nvuillam merged 3 commits intooxsecurity:mainfrom
Conversation
- 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>
|
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>
|
@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 CauseThe descriptor had: cli_config_arg_name: "--config-file"
config_file_name: ".mypy.ini"This caused MegaLinter to build the command like: The problem: The error was: The FixRemoved MyPy will auto-detect config files ( CI is running now to verify the fix. |
There was a problem hiding this comment.
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.) |
There was a problem hiding this comment.
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.
nvuillam
left a comment
There was a problem hiding this comment.
looks good to me, thanks for the updates :)


Summary
disabled: truefrom PYTHON_NBQA_MYPY descriptordisabled_reasonthat was added as a temporary fixmake megalinter-buildProblem
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: Removedisabled: trueanddisabled_reasonRelated
.ipynbfiles #6904 resolutionCo-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:
This configuration caused MegaLinter to build the command:
The Problem:
--config-filewas being passed to nbqa (which doesn't recognize it), instead of being passed through to mypy.The actual error was:
The Fix
Commit
faf9911307removedcli_config_arg_nameandconfig_file_namefrom the descriptor. The command now correctly builds as: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
nbqato the container images, which can change CI behavior (new failures/time) and slightly increases image/build complexity.Overview
Re-enables the
PYTHON_NBQA_MYPYlinter 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-fileflag throughnbqa).Regenerates build artifacts to include
python_nbqa_mypyin the linter matrix and flavors, and updates the base/flavor Dockerfiles to installnbqa(new/venvs/nbqaplus 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.