The Fix
pip install pydantic==1.10.19
Based on closed pydantic/pydantic issue #10618 · 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%.
@@ -767,6 +767,12 @@ def _unpack_refs_defs(self, schema: CoreSchema) -> CoreSchema:
return schema
+ def _resolve_self_type(self, obj: Any) -> Any:
+ obj = self.model_type_stack.get()
+ if obj is None:
Traceback (most recent call last):
File "C:\Users\kchon\OneDrive\Desktop\pydantic\new.py", line 7, in <module>
class A(BaseModel):
File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\_internal\_model_construction.py", line 227, in __new__
complete_model_class(
File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\_internal\_model_construction.py", line 679, in complete_model_class
cls.__pydantic_validator__ = create_schema_validator(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\plugin\_schema_validator.py", line 50, in create_schema_validator
return SchemaValidator(schema, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.SchemaError: Error building "model" validator:
SchemaError: Error building "model-fields" validator:
SchemaError: Field "self_field":
SchemaError: Error building "is-subclass" validator:
TypeError: '_SpecialForm' object cannot be converted to 'PyType'
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.19\nWhen NOT to use: This fix should not be used if the model relies on unsupported type constructs.\n\n
Why This Fix Works in Production
- Trigger: class A(BaseModel):
- Mechanism: The usage of `type[Self]` caused a TypeError due to improper handling in the schema validator
- Why the fix works: Supports the usage of `type` with `typing.Self` and type aliases, fixing errors related to these types. (first fixed release: 1.10.19).
- 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 usage of `type[Self]` caused a TypeError due to improper handling in the schema validator
- Surfaces as: Traceback (most recent call last):
Proof / Evidence
- GitHub issue: #10618
- Fix PR: https://github.com/pydantic/pydantic/pull/10621
- First fixed release: 1.10.19
- 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.31
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“### Initial Checks - [X] I confirm that I'm using Pydantic V2 ### Description ### Traceback ### Example Code ### Python, Pydantic & OS Version”
Failure Signature (Search String)
- class A(BaseModel):
Error Message
Stack trace
Error Message
-------------
Traceback (most recent call last):
File "C:\Users\kchon\OneDrive\Desktop\pydantic\new.py", line 7, in <module>
class A(BaseModel):
File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\_internal\_model_construction.py", line 227, in __new__
complete_model_class(
File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\_internal\_model_construction.py", line 679, in complete_model_class
cls.__pydantic_validator__ = create_schema_validator(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\plugin\_schema_validator.py", line 50, in create_schema_validator
return SchemaValidator(schema, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.SchemaError: Error building "model" validator:
SchemaError: Error building "model-fields" validator:
SchemaError: Field "self_field":
SchemaError: Error building "is-subclass" validator:
TypeError: '_SpecialForm' object cannot be converted to 'PyType'
Minimal Reproduction
Traceback (most recent call last):
File "C:\Users\kchon\OneDrive\Desktop\pydantic\new.py", line 7, in <module>
class A(BaseModel):
File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\_internal\_model_construction.py", line 227, in __new__
complete_model_class(
File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\_internal\_model_construction.py", line 679, in complete_model_class
cls.__pydantic_validator__ = create_schema_validator(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\plugin\_schema_validator.py", line 50, in create_schema_validator
return SchemaValidator(schema, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.SchemaError: Error building "model" validator:
SchemaError: Error building "model-fields" validator:
SchemaError: Field "self_field":
SchemaError: Error building "is-subclass" validator:
TypeError: '_SpecialForm' object cannot be converted to 'PyType'
Environment
- Pydantic: 2
What Broke
Users experienced TypeErrors when defining models with `type[Self]` in Pydantic.
Why It Broke
The usage of `type[Self]` caused a TypeError due to improper handling in the schema validator
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.19
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/10621
First fixed release: 1.10.19
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the model relies on unsupported type constructs.
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.19 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.