Skip to content

Commit 871bf9d

Browse files
slight tweak to composition stub
1 parent 373cd9a commit 871bf9d

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

emmet-core/emmet/core/stubs.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
# mypy: ignore-errors
2-
# isort: off
3-
"""
4-
This module stubs some pymatgen classes that implement custom behavior
5-
outside the standard MSONable model
6-
"""
7-
from typing import Dict
1+
"""Stub some pymatgen classes with behaviors besides those of MSONable."""
82

93
import pymatgen.core.composition
104
from pydantic import RootModel
@@ -20,7 +14,7 @@
2014
class StubComposition(RootModel):
2115
"""A dictionary mapping element to total quantity"""
2216

23-
root: Dict[Element, float]
17+
root: dict[Element, float]
2418

2519

2620
@classmethod # type: ignore
@@ -34,5 +28,5 @@ def validate_composition(cls, v):
3428
return pymatgen.core.composition.Composition(**v)
3529

3630

37-
pymatgen.core.composition.Composition.__pydantic_model__ = StubComposition
38-
pymatgen.core.composition.Composition.__get_validators__ = get_validators
31+
setattr(pymatgen.core.composition.Composition,"__pydantic_model__", StubComposition)
32+
setattr(pymatgen.core.composition.Composition,"__get_validators__", get_validators)

0 commit comments

Comments
 (0)