import os def check_file(path): filename = os.path.basename(path) classname = filename.replace('.yaml', '') with open(path, 'r') as f: lines = f.readlines() in_imports = False for i, line in enumerate(lines): stripped = line.strip() if stripped == "imports:": in_imports = True continue if in_imports: if not stripped.startswith("-"): if stripped and not stripped.startswith("#"): in_imports = False else: import_path = stripped.lstrip("- ").strip() if import_path == f"./{classname}": print(f"Self-import found in {path} at line {i+1}: {stripped}") 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")