@@ -273,14 +273,15 @@ def __init__(
273273 suffix_split = cls .suffix .split ("/" )
274274
275275 if len (suffix_split ) == 1 :
276+ # Disable monty decode on nested data which may give errors
277+ monty_disable = cls in [TaskRester , ProvenanceRester ]
278+ monty_decode = False if monty_disable else monty_decode
276279 rester = cls (
277280 api_key = api_key ,
278281 endpoint = self .endpoint ,
279282 include_user_agent = include_user_agent ,
280283 session = self .session ,
281- monty_decode = monty_decode
282- if cls not in [TaskRester , ProvenanceRester ] # type: ignore
283- else False , # Disable monty decode on nested data which may give errors
284+ monty_decode = monty_decode ,
284285 use_document_model = use_document_model ,
285286 headers = self .headers ,
286287 mute_progress_bars = self .mute_progress_bars ,
@@ -303,14 +304,14 @@ def __init__(
303304 def __core_custom_getattr (_self , _attr , _rester_map ):
304305 if _attr in _rester_map :
305306 cls = _rester_map [_attr ]
307+ monty_disable = cls in [TaskRester , ProvenanceRester ]
308+ monty_decode = False if monty_disable else monty_decode
306309 rester = cls (
307310 api_key = api_key ,
308311 endpoint = self .endpoint ,
309312 include_user_agent = include_user_agent ,
310313 session = self .session ,
311- monty_decode = monty_decode
312- if cls not in [TaskRester , ProvenanceRester ] # type: ignore
313- else False , # Disable monty decode on nested data which may give errors
314+ monty_decode = monty_decode ,
314315 use_document_model = use_document_model ,
315316 headers = self .headers ,
316317 mute_progress_bars = self .mute_progress_bars ,
@@ -1359,9 +1360,11 @@ def get_charge_density_from_material_id(
13591360
13601361 latest_doc = max ( # type: ignore
13611362 results ,
1362- key = lambda x : x .last_updated # type: ignore
1363- if self .use_document_model
1364- else x ["last_updated" ], # type: ignore
1363+ key = lambda x : (
1364+ x .last_updated # type: ignore
1365+ if self .use_document_model
1366+ else x ["last_updated" ]
1367+ ), # type: ignore
13651368 )
13661369 task_id = (
13671370 latest_doc .task_id if self .use_document_model else latest_doc ["task_id" ]
0 commit comments