Skip to content

Commit 9766074

Browse files
committed
fix compatibility with old Python
1 parent 26d8574 commit 9766074

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

deepmd/dpmodel/utils/serialization.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,14 @@ def format_list_keys(kk: str) -> str:
365365
return f"[{keys[0]}...{keys[-1]}]"
366366
return kk
367367

368+
def format_value(vv: str) -> str:
369+
return vv.replace(
370+
linebreak,
371+
linebreak + (pipe if ii < len(children_buff) - 1 else blank),
372+
)
373+
368374
buff.extend(
369-
f"{tee if ii < len(children_buff) - 1 else elbow}{format_list_keys(kk)} -> {
370-
vv.replace(
371-
linebreak,
372-
linebreak + (pipe if ii < len(children_buff) - 1 else blank),
373-
)
374-
}"
375+
f"{tee if ii < len(children_buff) - 1 else elbow}{format_list_keys(kk)} -> {format_value(vv)}"
375376
for ii, (kk, vv) in enumerate(children_buff)
376377
)
377378
return "\n".join(buff)

0 commit comments

Comments
 (0)