import yaml import os def check_file(path): try: with open(path, 'r') as f: data = yaml.safe_load(f) except Exception as e: print(f"Error parsing {path}: {e}") return if 'classes' in data: for class_name, class_def in data['classes'].items(): if 'custodian_types' in class_def: print(f"Misplaced custodian_types found in {path} Class {class_name} (root level)") if 'slot_usage' in class_def and class_def['slot_usage']: for slot_name, slot_def in class_def['slot_usage'].items(): if slot_def and 'custodian_types' in slot_def: print(f"Misplaced custodian_types found in {path} Class {class_name} SlotUsage {slot_name}") if 'annotations' in class_def: ann = class_def['annotations'] if ann and 'custodian_types' in ann: val = ann['custodian_types'] if isinstance(val, list): print(f"List value found in {path} Class {class_name}: {val}") elif not isinstance(val, str): print(f"Non-string value found in {path} Class {class_name}: {val} (type: {type(val)})") if 'slots' in data: for slot_name, slot_def in data['slots'].items(): if 'custodian_types' in slot_def: print(f"Misplaced custodian_types found in {path} Slot {slot_name} (root level)") if 'annotations' in slot_def: ann = slot_def['annotations'] if ann and 'custodian_types' in ann: val = ann['custodian_types'] if isinstance(val, list): print(f"List value found in {path} Slot {slot_name}: {val}") def process_directory(directory): for root, dirs, files in os.walk(directory): for file in files: if file.endswith(".yaml"): check_file(os.path.join(root, file)) process_directory("schemas/20251121/linkml/modules/classes") process_directory("schemas/20251121/linkml/modules/slots")