The Fix
pip install pydantic==2.5.0
Based on closed pydantic/pydantic issue #8745 · 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%.
@@ -89,6 +89,7 @@
BASEMODEL_FULLNAME = 'pydantic.main.BaseModel'
BASESETTINGS_FULLNAME = 'pydantic_settings.main.BaseSettings'
+ROOT_MODEL_FULLNAME = 'pydantic.root_model.RootModel'
MODEL_METACLASS_FULLNAME = 'pydantic._internal._model_construction.ModelMetaclass'
FIELD_FULLNAME = 'pydantic.fields.Field'
from pydantic import RootModel
SimpleID = RootModel[str]
class FancyID(RootModel[str]):
def __str__(self) -> str:
return self.root
class HackyID(RootModel[str]):
def __init__(self, root: str):
super().__init__(root=root)
def __str__(self) -> str:
return self.root
# from https://docs.pydantic.dev/2.5/concepts/models/#rootmodel-and-custom-root-types
# "The root value can be passed to the model __init__ or model_validate via the first and only argument."
foo = SimpleID('foo')
bar = FancyID('bar') # Expected 0 positional arguments Pylance(reportGeneralTypeIssues)
hack = HackyID('hack')
print(foo)
print(bar)
print(hack)
assert str(bar) == 'bar' # works just fine
assert str(hack) == 'hack'
bar = FancyID.model_validate('bar') # no type errors
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.5.0\nWhen NOT to use: This fix is not applicable for versions prior to 2.6.\n\n
Why This Fix Works in Production
- Trigger: Type error on initialization of classes derived from RootModel
- Mechanism: `mypy` no longer errors when a subclass of `RootModel` is instantiated without a `root` keyword argument.
- Why the fix works: `mypy` no longer errors when a subclass of `RootModel` is instantiated without a `root` keyword argument. (first fixed release: 2.5.0).
- 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
- Shows up under Python 3.11 in real deployments (not just unit tests).
- Production symptom (often without a traceback): Type error on initialization of classes derived from RootModel
Proof / Evidence
- GitHub issue: #8745
- Fix PR: https://github.com/pydantic/pydantic/pull/7677
- First fixed release: 2.5.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.40
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@WarpedPixel you are still on 2.5.x, where a positional argument to a RootModel was not allowed”
“@WarpedPixel, Thanks for reporting this”
“You are correct of course. Just verified with 2.6.1 and it works as expected.”
Failure Signature (Search String)
- Type error on initialization of classes derived from RootModel
- Note that the code works in all cases, however the type system (Pylance in this case) does not understand it correctly. Moreover, workarounds like the one in `HackyID` below, or
Copy-friendly signature
Failure Signature
-----------------
Type error on initialization of classes derived from RootModel
Note that the code works in all cases, however the type system (Pylance in this case) does not understand it correctly. Moreover, workarounds like the one in `HackyID` below, or only initializing `FancyID` with `model_validate()` also work.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Type error on initialization of classes derived from RootModel
Note that the code works in all cases, however the type system (Pylance in this case) does not understand it correctly. Moreover, workarounds like the one in `HackyID` below, or only initializing `FancyID` with `model_validate()` also work.
Minimal Reproduction
from pydantic import RootModel
SimpleID = RootModel[str]
class FancyID(RootModel[str]):
def __str__(self) -> str:
return self.root
class HackyID(RootModel[str]):
def __init__(self, root: str):
super().__init__(root=root)
def __str__(self) -> str:
return self.root
# from https://docs.pydantic.dev/2.5/concepts/models/#rootmodel-and-custom-root-types
# "The root value can be passed to the model __init__ or model_validate via the first and only argument."
foo = SimpleID('foo')
bar = FancyID('bar') # Expected 0 positional arguments Pylance(reportGeneralTypeIssues)
hack = HackyID('hack')
print(foo)
print(bar)
print(hack)
assert str(bar) == 'bar' # works just fine
assert str(hack) == 'hack'
bar = FancyID.model_validate('bar') # no type errors
Environment
- Python: 3.11
- Pydantic: 2
What Broke
Users experience type errors when initializing RootModel subclasses with positional arguments.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.5.0
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/7677
First fixed release: 2.5.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable for versions prior to 2.6.
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.5.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.