Skip to content

Update mypy to 2.4.0 in the static analysis step - #700

Merged
quantconnect-kronos[bot] merged 2 commits into
masterfrom
update-mypy-2.4.0
Nov 3, 2026
Merged

quantconnect-kronos[bot] merged 2 commits into
masterfrom
update-mypy-2.4.0

Conversation

@Martin-Molinero

@Martin-Molinero Martin-Molinero commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Updates the static analysis step's mypy from 1.19.1 to 2.4.0.

static_analysis.py keeps only mypy's [call-arg] errors, and they're the same under both versions:

  • On master: neither version reports any.
  • With a call missing an argument added on purpose: both report it, with the same message on the same line.

mypy 2.x requires Python 3.10 or newer (every release from 1.20.0 on declares Requires-Python >=3.10), so pip install mypy==2.4.0 failed on the Python 3.9 build. The static analysis step now skips Python 3.9. It still runs on Linux for 3.10 to 3.14, and the 3.9 jobs still install and run the tests.

Testing

On Python 3.11, with requirements.txt, mypy==2.4.0 and flake8==7.3.0 installed:

  • python static_analysis.py: exit 0, with no call-argument mismatches, no undefined variables and the same 5 unused-import warnings as before.
  • python -m pytest -s -rs: 2784 passed, 82 skipped.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Martin-Molinero Martin-Molinero added the kronos:develop Request develop label Nov 3, 2026
@quantconnect-kronos quantconnect-kronos Bot added kronos:develop:queued develop: queued kronos:develop:working develop: in progress and removed kronos:develop Request develop kronos:develop:queued develop: queued labels Nov 3, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@quantconnect-kronos

Copy link
Copy Markdown
Contributor

The Python 3.9 build failed at pip install mypy==2.4.0 because mypy 2.x needs Python 3.10 or newer. I made the static analysis step skip 3.9, so the 3.9 jobs still run the tests. setup.py still declares python_requires=">= 3.9". Would you rather drop 3.9 from python-versions.txt (and python_requires) instead? I left that alone because it would change which Python versions the CLI supports.

@quantconnect-kronos
quantconnect-kronos Bot marked this pull request as draft November 3, 2026 19:44
@quantconnect-kronos

Copy link
Copy Markdown
Contributor

The test (windows-latest, 3.9) failure isn't from this change. The static analysis step was skipped on that job, as intended. One test failed under "Run tests": tests/ui/test_app.py::test_stopping_a_cloud_backtest_can_delete_it, with textual.worker.WorkerCancelled: Worker was cancelled, and did not complete. (2793 passed). The same test fails the same way on master's latest Build run (run 41521423597, test (windows-latest, 3.10)), so it's flaky on Windows. The other red jobs in this run were cancelled by fail-fast and didn't fail on their own. I re-ran the failed jobs.

@quantconnect-kronos quantconnect-kronos Bot added the kronos:review Request review label Nov 3, 2026
@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added kronos:review:queued review: queued kronos:review:working review: in progress and removed kronos:review Request review kronos:review:queued review: queued labels Nov 3, 2026
@quantconnect-kronos-reviewer
quantconnect-kronos-reviewer Bot marked this pull request as ready for review November 3, 2026 20:57

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approving. This changes only CI: the static analysis step now installs mypy 2.4.0 and skips Python 3.9, and no shipped code changes.

What I checked

  • CI: all green on 8a798c3, in both the push run and the pull_request run. In test (ubuntu-22.04, 3.10) the log shows mypy-2.4.0 installed and BUILD PASSED with 5 warning(s). In test (ubuntu-22.04, 3.9) the step is skipped and the tests and README check still run. The windows-latest, 3.9 failure from the earlier attempt was the flaky test_stopping_a_cloud_backtest_can_delete_it on a step this change doesn't touch, and it passed on re-run.
  • No silent pass: static_analysis.py keeps only [call-arg] lines, so it would also pass if mypy errored out on a removed flag. I ran mypy 2.4.0 locally on this branch (Python 3.11) with the script's exact flags. It type-checks the whole package: 608 diagnostics across the usual codes, and no crash or flag error.
  • Same result as before: both 1.19.1 and 2.4.0 report 0 [call-arg] lines on this branch. When I added a Logger().info() call with no argument, python static_analysis.py under 2.4.0 reported Missing positional argument "message" ... [call-arg] and failed the build, as it should.
  • Skipping 3.9: the check reads the same source on every interpreter and only looks at call arguments, so running it on 3.10 to 3.14 keeps its coverage. 3.9 support itself (python_requires, the test matrix) is unchanged. Whether to drop 3.9 is a separate decision and doesn't belong in this change.
  • No other file pins mypy. No other repository is affected.

Risk: I set risk:low. It's a two-line CI change that's easy to revert, users see no difference, and the evidence above backs it. An end-to-end run doesn't apply because the CLI's behavior doesn't change.

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added risk:low Low risk kronos:review Request review kronos:review:queued review: queued and removed kronos:review:working review: in progress kronos:review Request review labels Nov 3, 2026
@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot added kronos:review:working review: in progress and removed kronos:review:queued review: queued labels Nov 3, 2026

@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approving: no blocking findings in this CI-only change.

Verification:

  • Both current push and pull-request CI runs passed all 30 test jobs. All ten Linux Python 3.10–3.14 static-analysis steps passed; the two Linux Python 3.9 analysis steps were skipped while their tests and README checks passed. The Python 3.10 log confirms installation of mypy 2.4.0 and BUILD PASSED with 5 warning(s).
  • Compared mypy 1.19.1 and 2.4.0 locally on Python 3.11 using the repository requirements and flake8 7.3.0. Both pass python static_analysis.py on unchanged source with the same five warnings. Temporary missing-argument, extra-positional-argument, and unexpected-keyword probes each produce the same [call-arg] diagnostics under both versions, and the script exits 1. The probes were removed afterward.
  • Upstream package metadata confirms mypy 2.4.0 requires Python >=3.10. Python 3.9 runtime support and its test matrix remain unchanged, although its separate static-analysis coverage is intentionally removed. No other repository update is needed.

An application end-to-end run is not applicable: no shipped CLI code or behavior changes.

Risk: risk:low retained. This is a small, readily reversible CI dependency/condition change, backed by passing matrix jobs and positive/negative analysis checks, with no user-facing API change.

@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot removed the kronos:review:working review: in progress label Nov 3, 2026
@quantconnect-kronos
quantconnect-kronos Bot merged commit 9ba4213 into master Nov 3, 2026
95 of 110 checks passed
@quantconnect-kronos quantconnect-kronos Bot removed the kronos:develop:working develop: in progress label Nov 3, 2026
@quantconnect-kronos
quantconnect-kronos Bot deleted the update-mypy-2.4.0 branch November 3, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Low risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant