Skip to content

Upgrade mypy to 2.1.0 and optimize type checking#29

Merged
tsvikas merged 5 commits into
mainfrom
claude/upgrade-mypy-2.1-MaCxi
May 14, 2026
Merged

Upgrade mypy to 2.1.0 and optimize type checking#29
tsvikas merged 5 commits into
mainfrom
claude/upgrade-mypy-2.1-MaCxi

Conversation

@tsvikas
Copy link
Copy Markdown
Owner

@tsvikas tsvikas commented May 14, 2026

Summary

This PR upgrades mypy from version 1.20.0 to 2.1.0 and optimizes the type checking configuration and CI workflow.

Key Changes

  • Dependency upgrade: Updated mypy from ~=1.20.0 to ~=2.1.0 and removed the [native-parser] extra (no longer needed in 2.1.0)
  • Configuration update: Removed local_partial_types = true from mypy config, which is no longer necessary with mypy 2.1.0
  • Performance optimization: Added --num-workers 4 flag to mypy invocation in CI to parallelize type checking across 4 workers
  • Documentation: Updated mypy version reference in config comments from 1.20 to 2.1

Implementation Details

The removal of local_partial_types configuration indicates that mypy 2.1.0 has improved its handling of partial types, making this explicit setting redundant. The parallel worker configuration in CI should reduce type checking time without requiring any code changes.

https://claude.ai/code/session_01DSZJX4JKn2or8vLdmoGECt

claude added 2 commits May 14, 2026 09:46
- Bump mypy from ~=1.20.0 to ~=2.1.0.
- Remove local_partial_types from config (enabled by default in 2.1).
- Pass --num-workers 4 in CI to match GitHub Actions runner vCPUs.

https://claude.ai/code/session_01DSZJX4JKn2or8vLdmoGECt
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Hard-coding --num-workers 4 in the CI workflow may underutilize or oversubscribe cores on different runners; consider either omitting the flag to use mypy’s default parallelism or deriving the worker count dynamically (e.g., via $(nproc) or a matrix/env variable).
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Hard-coding `--num-workers 4` in the CI workflow may underutilize or oversubscribe cores on different runners; consider either omitting the flag to use mypy’s default parallelism or deriving the worker count dynamically (e.g., via `$(nproc)` or a matrix/env variable).

## Individual Comments

### Comment 1
<location path="project_name/.github/workflows/ci.yml.jinja" line_range="79-80" />
<code_context>
         run: uv pip list
       - name: Run mypy
-        run: uv run --no-sync mypy
+        run: uv run --no-sync mypy --num-workers 4

   dependencies:
</code_context>
<issue_to_address>
**suggestion (performance):** Hardcoding `--num-workers 4` may underuse or oversubscribe CI runners; consider deriving it from available CPUs.

Fixing this at 4 assumes a specific runner size and may slow CI on larger machines or overload smaller ones. Instead, consider deriving the value from available CPUs (e.g. `--num-workers "$(nproc)"` on Linux) or omitting it and relying on mypy’s default unless you have data showing 4 is optimal.

```suggestion
      - name: Run mypy
        run: uv run --no-sync mypy --num-workers "$(nproc)"
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread project_name/.github/workflows/ci.yml.jinja Outdated
claude added 3 commits May 14, 2026 09:59
Mirrors the CI mypy parallelism. Hardcoded since macOS lacks nproc.

https://claude.ai/code/session_01DSZJX4JKn2or8vLdmoGECt
dmypy crashes when --num-workers is passed (FileExistsError in worker
init) — the parallel-worker mode is incompatible with the daemon. Keep
the flag only on the one-shot mypy invocation in CI.

https://claude.ai/code/session_01DSZJX4JKn2or8vLdmoGECt
@tsvikas tsvikas merged commit 6cce755 into main May 14, 2026
5 checks passed
@tsvikas tsvikas deleted the claude/upgrade-mypy-2.1-MaCxi branch May 14, 2026 10:16
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.

2 participants