fromtypingimportAnyimportyamlimportpathlibdefload_yaml(path:str)->Any:"""Load a single-document YAML file using safe_load."""withopen(path,"r",encoding="utf-8")asf:returnyaml.safe_load(f)if__name__=="__main__":file=pathlib.Path(__file__).parent.joinpath("simple.yaml").as_posix()data=load_yaml(file)print(data)
YAML Language support uses JSON Schemas to understand the shape of a YAML file, including its value sets, defaults and descriptions. The schema support is shipped with JSON Schema Draft 7.
The association of a YAML file to a schema can be done either in the YAML file itself using a modeline or in the User or Workspace settings under the property yaml.schemas. in vscode settings