chore(deps): upgrade mypy to 2.3.1 - #1298
Merged
Merged
Conversation
Deploying infrahub-sdk-python with
|
| 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 |
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
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
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
force-pushed
the
chore/upgrade-mypy-2.3.1
branch
from
August 28, 2026 08:40
bb2477b to
d6dc76d
Compare
Contributor
There was a problem hiding this comment.
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
ogenstad
commented
Aug 28, 2026
| 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 |
Contributor
Author
There was a problem hiding this comment.
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
marked this pull request as ready for review
August 28, 2026 09:12
polmichel
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Upgrades the
mypydev dependency from1.11.2to2.3.1, primarily for the speed improvement.This is a tooling-only change. mypy 2.3.1 also changed how it joins
AnywithNone(it no longer collapsesAny | Nonedown toAny), which surfacedInfrahubNode.id- inferred fromdata.get("id", None)- as a nullable union and produced 12 errors where an id feeds astr-typed slot. To keep the upgrade purely mechanical,self.idis pinned toAny, preserving the exact type mypy inferred before 2.3.1.Non-goals: this PR intentionally does not tighten
.idtyping or add any runtime validation - that would change behavior and could force SDK consumers to adapt their own code.What changed
mypy==1.11.2->mypy==2.3.1in thelintdependency group (pyproject.toml,uv.lock).self.id: AnyinInfrahubNode.__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.tomland theself.id: Anyannotation ininfrahub_sdk/node/node.py.How to test
Impact & rollout