Skip to content

chore(deps): upgrade mypy to 2.3.1 - #1298

Merged
ogenstad merged 1 commit into
stablefrom
chore/upgrade-mypy-2.3.1
Aug 28, 2026
Merged

chore(deps): upgrade mypy to 2.3.1#1298
ogenstad merged 1 commit into
stablefrom
chore/upgrade-mypy-2.3.1

Conversation

@ogenstad

@ogenstad ogenstad commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Why

Upgrades the mypy dev dependency from 1.11.2 to 2.3.1, primarily for the speed improvement.

This is a tooling-only change. mypy 2.3.1 also changed how it joins Any with None (it no longer collapses Any | None down to Any), which surfaced InfrahubNode.id - inferred from data.get("id", None) - as a nullable union and produced 12 errors where an id feeds a str-typed slot. To keep the upgrade purely mechanical, self.id is pinned to Any, preserving the exact type mypy inferred before 2.3.1.

Non-goals: this PR intentionally does not tighten .id typing or add any runtime validation - that would change behavior and could force SDK consumers to adapt their own code.

What changed

  • Bumped mypy==1.11.2 -> mypy==2.3.1 in the lint dependency group (pyproject.toml, uv.lock).
  • Annotated self.id: Any in InfrahubNode.__init__ to preserve pre-2.3.1 inference. No other source changes; no behavior change; public API unchanged.

How to review

Two lines of substance: the version bump in pyproject.toml and the self.id: Any annotation in infrahub_sdk/node/node.py.

How to test

uv sync --all-groups --all-extras
uv run mypy --show-error-codes infrahub_sdk   # Success: no issues found in 158 source files
uv run ty check .                             # All checks passed!
uv run invoke lint-code                       # ruff + ty + mypy all pass

Impact & rollout

  • Backward compatibility: No public API or behavior changes.
  • Config/env changes: None beyond the dev dependency pin.
  • Deployment notes: Safe to deploy - dev-tooling change only.

@ogenstad ogenstad added type/housekeeping Maintenance task ci/skip-changelog Don't include this PR in the changelog labels Aug 28, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 28, 2026

Copy link
Copy Markdown

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: d6dc76d
Status: ✅  Deploy successful!
Preview URL: https://ab2d43db.infrahub-sdk-python.pages.dev
Branch Preview URL: https://chore-upgrade-mypy-2-3-1.infrahub-sdk-python.pages.dev

View logs

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##           stable    #1298      +/-   ##
==========================================
- Coverage   84.24%   84.23%   -0.01%     
==========================================
  Files         147      147              
  Lines       13066    13045      -21     
  Branches     1940     1930      -10     
==========================================
- Hits        11007    10989      -18     
+ Misses       1494     1493       -1     
+ Partials      565      563       -2     
Flag Coverage Δ
integration-tests 39.08% <100.00%> (-0.10%) ⬇️
python-3.10 57.05% <100.00%> (+0.06%) ⬆️
python-3.11 57.05% <100.00%> (+0.07%) ⬆️
python-3.12 57.07% <100.00%> (+0.07%) ⬆️
python-3.13 57.07% <100.00%> (+0.07%) ⬆️
python-3.14 57.05% <100.00%> (+0.06%) ⬆️
python-filler-3.12 23.68% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/node/node.py 87.77% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 5 files

Re-trigger cubic

@github-actions github-actions Bot added the type/documentation Improvements or additions to documentation label Aug 28, 2026
mypy 2.3.1 is faster. It also stopped collapsing `Any | None` to `Any`, so
InfrahubNode.id (inferred from data.get("id", None)) began surfacing as a
nullable union and produced 12 errors where an id feeds a str-typed slot.

Pin self.id to Any to preserve the exact pre-2.3.1 behavior. This keeps the
upgrade a tooling-only change with no runtime or public-API impact.
@ogenstad
ogenstad force-pushed the chore/upgrade-mypy-2.3.1 branch from bb2477b to d6dc76d Compare August 28, 2026 08:40
@github-actions github-actions Bot removed the type/documentation Improvements or additions to documentation label Aug 28, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread infrahub_sdk/node/node.py
Comment thread infrahub_sdk/node/node.py
self.id = data.get("id", None) if isinstance(data, dict) else None
# Typed as Any to preserve pre-2.3.1 mypy behavior: newer mypy no longer collapses
# ``Any | None`` to ``Any``, which would otherwise force None-narrowing on every id use.
self.id: Any = data.get("id", None) if isinstance(data, dict) else None

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a change where the .id previously got assigned the type Any | None. We already have multiple ignores throughout the codebase in pyproject.toml with regards to ty for this line. It's something that we'd want to clean up at some point but it won't be part of this change.

@ogenstad
ogenstad marked this pull request as ready for review August 28, 2026 09:12
@ogenstad
ogenstad requested a review from a team as a code owner August 28, 2026 09:12
@ogenstad
ogenstad merged commit 7e48cd2 into stable Aug 28, 2026
21 checks passed
@ogenstad
ogenstad deleted the chore/upgrade-mypy-2.3.1 branch August 28, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/skip-changelog Don't include this PR in the changelog type/housekeeping Maintenance task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants