The Fix
pip install pydantic==2.10.4
Based on closed pydantic/pydantic issue #10474 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -761,6 +761,10 @@ def collect_field_or_class_var_from_stmt( # noqa C901
node.type = AnyType(TypeOfAny.from_error)
+ if node.is_final and has_default:
+ # TODO this path should be removed (see https://github.com/pydantic/pydantic/issues/11119)
+ return PydanticModelClassVar(lhs.name)
from typing import Final
from pydantic import RootModel
class A(RootModel[str]):
a: Final = 1 # error: Only `root` is allowed as a field of a `RootModel` [pydantic-field]
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install pydantic==2.10.4\nWhen NOT to use: This fix is not applicable if the behavior of Final fields is intended to change in future versions.\n\n
Why This Fix Works in Production
- Trigger: (🐞) false positive mypy error "Only `root` is allowed as a field of a `RootModel`"
- Mechanism: The mypy plugin incorrectly handles Final fields with default values in RootModel
- Why the fix works: Fixes a false positive mypy error regarding Final fields in RootModel by correctly inferring them as class variables. (first fixed release: 2.10.4).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- The mypy plugin incorrectly handles Final fields with default values in RootModel
- Production symptom (often without a traceback): (🐞) false positive mypy error "Only `root` is allowed as a field of a `RootModel`"
Proof / Evidence
- GitHub issue: #10474
- Fix PR: https://github.com/pydantic/pydantic/pull/11121
- First fixed release: 2.10.4
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.61
Verified Execution
We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.
- Status: PASS
- Ran: 2026-02-11T16:52:29Z
- Package: pydantic
- Fixed: 2.10.4
- Mode: fixed_only
- Outcome: ok
Logs
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“This will be fixed in https://github.com/pydantic/pydantic/pull/11121”
“The typing specification regarding Final was updated this year, and it seems that we don't apply the same semantics, but we probably should”
“Indeed, looks like a bug. Fixing is relatively low priority, but PRs welcome!”
Failure Signature (Search String)
- (🐞) false positive mypy error "Only `root` is allowed as a field of a `RootModel`"
- a `Final` with a default value is not a field, it's a `ClassVar`, and pydantic correctly handles this at runtime, but the mypy plugin is incorrect here
Copy-friendly signature
Failure Signature
-----------------
(🐞) false positive mypy error "Only `root` is allowed as a field of a `RootModel`"
a `Final` with a default value is not a field, it's a `ClassVar`, and pydantic correctly handles this at runtime, but the mypy plugin is incorrect here
Error Message
Signature-only (no traceback captured)
Error Message
-------------
(🐞) false positive mypy error "Only `root` is allowed as a field of a `RootModel`"
a `Final` with a default value is not a field, it's a `ClassVar`, and pydantic correctly handles this at runtime, but the mypy plugin is incorrect here
Minimal Reproduction
from typing import Final
from pydantic import RootModel
class A(RootModel[str]):
a: Final = 1 # error: Only `root` is allowed as a field of a `RootModel` [pydantic-field]
Environment
- Pydantic: 2
What Broke
Developers encounter false positive errors when using Final fields in RootModel, causing confusion.
Why It Broke
The mypy plugin incorrectly handles Final fields with default values in RootModel
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.10.4
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/pydantic/pydantic/pull/11121
First fixed release: 2.10.4
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if the behavior of Final fields is intended to change in future versions.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
- Upgrade behind a canary and run integration tests against the canary before 100% rollout.
Version Compatibility Table
| Version | Status |
|---|---|
| 2.10.4 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.