Skip to content

PendingDeprecationWarning for YAML(typ="unsafe", pure=True) in io.cp2k.sets #4444

@DanielYang59

Description

@DanielYang59

# Necessary if matching data to CP2K data files
if have_element_file:
with open(elem_file_path, encoding="utf-8") as file:
yaml = YAML(typ="unsafe", pure=True)
DATA = yaml.load(file)

/Users/yang/developer/pymatgen/src/pymatgen/io/cp2k/sets.py:444: PendingDeprecationWarning: 
  you should no longer specify 'unsafe'.
  For **dumping only** use yaml=YAML(typ='full')
  
    yaml = YAML(typ="unsafe", pure=True)

https://yaml.dev/doc/ruamel.yaml/ it might be removed anytime I guess as the deadline was end of 2023:

There will be at least one more potentially breaking change in the 0.18 series: YAML(typ='unsafe') now has a pending deprecation warning and is going to be deprecated, probably before the end of 2023. If you only use it to dump, please use the new YAML(typ='full'), the result of that can be safely loaded with a default instance YAML(), as that will get you inspectable, tagged, scalars, instead of executed Python functions/classes. (You should probably add constructors for what you actually need, but I do consider adding a ruamel.yaml.unsafe package that will re-add the typ='unsafe' option. Please adjust/pin your dependencies accordingly if necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions