Skip to content

Commit 0b99e10

Browse files
tweak to ensure machinery matches with emmet
1 parent f996c72 commit 0b99e10

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pymatgen/io/validation/common.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@
99
from monty.serialization import loadfn
1010
import os
1111
from pathlib import Path
12-
from pydantic import BaseModel, Field, model_validator, model_serializer, PrivateAttr, PlainSerializer, BeforeValidator
12+
from pydantic import (
13+
BaseModel,
14+
Field,
15+
model_validator,
16+
model_serializer,
17+
PrivateAttr,
18+
PlainSerializer,
19+
BeforeValidator,
20+
RootModel,
21+
)
1322
from typing import TYPE_CHECKING, Any, Annotated, TypeAlias
1423

1524
from pymatgen.core import Structure
@@ -54,6 +63,14 @@ def _msonable_from_str(obj: Any, cls: type[MSONable]) -> MSONable:
5463
]
5564

5665

66+
class _MsonStrType(RootModel):
67+
root: str
68+
69+
70+
for pmg_obj in (Incar, Kpoints, Structure):
71+
setattr(pmg_obj, "__type_adapter__", _MsonStrType)
72+
73+
5774
class ValidationError(Exception):
5875
"""Define custom exception during validation."""
5976

0 commit comments

Comments
 (0)