The Fix
pip install pydantic==1.10.18
Based on closed pydantic/pydantic issue #9936 · 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%.
@@ -308,6 +308,9 @@ def from_attributes_callback(ctx: MethodContext) -> Type:
if pydantic_metadata is None:
return ctx.default_return_type
+ if not any(base.fullname == BASEMODEL_FULLNAME for base in model_type.type.mro):
+ # not a Pydantic v2 model
+ return ctx.default_return_type
from dataclasses import dataclass
from typing import Optional
from pydantic import BaseModel, ConfigDict
from pydantic.v1 import BaseModel as BaseModelV1
@dataclass
class CustomObject:
x: int
y: Optional[int]
obj = CustomObject(x=1, y=2)
class CustomModel(BaseModel):
model_config = ConfigDict(
from_attributes=True,
strict=True,
)
x: int
cm = CustomModel.from_orm(obj)
class CustomModelBadConfig(BaseModel):
model_config = ConfigDict(
strict=True,
)
x: int
cmnc = CustomModelBadConfig.from_orm(obj)
# should be a mypy error: "CustomModelBadConfig" does not have from_attributes=True [pydantic-orm]
class CustomV1Model(BaseModelV1):
class Config:
orm_mode = True
x: int
cmv1 = CustomV1Model.from_orm(obj)
# shouldn't be an error but gives: "CustomV1Model" does not have from_attributes=True [pydantic-orm]
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==1.10.18\nWhen NOT to use: This fix should not be applied if the deprecated decorator issue is unresolved.\n\n
Why This Fix Works in Production
- Trigger: pydantic.mypy `from_attributes` config check does not work with deprecated `.from_orm()` and gives false positives for `v1.BaseModel`
- Mechanism: Fixes false positives on v1 models in the mypy plugin for the from_orm check requiring from_attributes=True config.
- Why the fix works: Fixes false positives on v1 models in the mypy plugin for the from_orm check requiring from_attributes=True config. (first fixed release: 1.10.18).
- 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): pydantic.mypy `from_attributes` config check does not work with deprecated `.from_orm()` and gives false positives for `v1.BaseModel`
Proof / Evidence
- GitHub issue: #9936
- Fix PR: https://github.com/pydantic/pydantic/pull/9938
- First fixed release: 1.10.18
- 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.38
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Added a PR https://github.com/pydantic/pydantic/pull/9938 with described changes, the decorator issue still remains.”
“@sydney-runkle Would be worth splitting it into the @deprecation bug causing false negatives for pydantic-orm error and the one with fix PR for false positives…”
“I also wonder if the from_attributes check is in good place, as it is only checked for True and never used”
Failure Signature (Search String)
- pydantic.mypy `from_attributes` config check does not work with deprecated `.from_orm()` and gives false positives for `v1.BaseModel`
- `pydantic.mypy.PydanticPlugin.get_method_hook` that is supposed to run `pydantic.mypy.from_attributes_callback` for each `from_orm` invocation does not work with
Copy-friendly signature
Failure Signature
-----------------
pydantic.mypy `from_attributes` config check does not work with deprecated `.from_orm()` and gives false positives for `v1.BaseModel`
`pydantic.mypy.PydanticPlugin.get_method_hook` that is supposed to run `pydantic.mypy.from_attributes_callback` for each `from_orm` invocation does not work with `@typing_extensions.deprecated` on `pydantic.main.BaseModel.from_orm`.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
pydantic.mypy `from_attributes` config check does not work with deprecated `.from_orm()` and gives false positives for `v1.BaseModel`
`pydantic.mypy.PydanticPlugin.get_method_hook` that is supposed to run `pydantic.mypy.from_attributes_callback` for each `from_orm` invocation does not work with `@typing_extensions.deprecated` on `pydantic.main.BaseModel.from_orm`.
Minimal Reproduction
from dataclasses import dataclass
from typing import Optional
from pydantic import BaseModel, ConfigDict
from pydantic.v1 import BaseModel as BaseModelV1
@dataclass
class CustomObject:
x: int
y: Optional[int]
obj = CustomObject(x=1, y=2)
class CustomModel(BaseModel):
model_config = ConfigDict(
from_attributes=True,
strict=True,
)
x: int
cm = CustomModel.from_orm(obj)
class CustomModelBadConfig(BaseModel):
model_config = ConfigDict(
strict=True,
)
x: int
cmnc = CustomModelBadConfig.from_orm(obj)
# should be a mypy error: "CustomModelBadConfig" does not have from_attributes=True [pydantic-orm]
class CustomV1Model(BaseModelV1):
class Config:
orm_mode = True
x: int
cmv1 = CustomV1Model.from_orm(obj)
# shouldn't be an error but gives: "CustomV1Model" does not have from_attributes=True [pydantic-orm]
Environment
- Python: 3.11
- Pydantic: 2
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.18
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/9938
First fixed release: 1.10.18
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if the deprecated decorator issue is unresolved.
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 |
|---|---|
| 1.10.18 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.