Skip to content

Commit d40cb19

Browse files
change to mprest warning
1 parent 2bf633d commit d40cb19

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

mp_api/client/mprester.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
2323
from requests import Session, get
2424

25-
from mp_api.client.core import BaseRester, MPRestError
25+
from mp_api.client.core import BaseRester, MPRestError, MPRestWarning
2626
from mp_api.client.core._oxygen_evolution import OxygenEvolution
2727
from mp_api.client.core.settings import MAPIClientSettings
2828
from mp_api.client.core.utils import load_json, validate_api_key, validate_ids
@@ -213,7 +213,9 @@ def __init__(
213213
if "monty_decode" in kwargs:
214214
warnings.warn(
215215
"Ignoring `monty_decode`, as it is no longer a supported option in `mp_api`."
216-
"The client by default returns results consistent with `monty_decode=True`."
216+
"The client by default returns results consistent with `monty_decode=True`.",
217+
stacklevel=2,
218+
category=MPRestWarning,
217219
)
218220

219221
# Check if emmet version of server is compatible

tests/test_mprester.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from pymatgen.io.vasp import Chgcar
3434

3535
from mp_api.client import MPRester
36-
from mp_api.client.core.exceptions import MPRestError
36+
from mp_api.client.core import MPRestError, MPRestWarning
3737
from mp_api.client.core.settings import MAPIClientSettings
3838

3939
from .conftest import requires_api_key
@@ -575,3 +575,7 @@ def test_oxygen_evolution_bad_input(self, mpr):
575575

576576
with pytest.raises(ValueError, match="No available insertion electrode data"):
577577
_ = mpr.get_oxygen_evolution("mp-2207", "Al")
578+
579+
def test_monty_decode_warning(self):
580+
with pytest.warns(MPRestWarning, match="Ignoring `monty_decode`"):
581+
MPRester(monty_decode=False)

0 commit comments

Comments
 (0)