import sys def check_ai_client(path): with open(path, 'r', encoding='utf-8') as f: lines = f.readlines() imports = [] internal_imports = [] for i, line in enumerate(lines): stripped = line.strip() if stripped.startswith('import ') or stripped.startswith('from '): if line.startswith('import ') or line.startswith('from '): imports.append((i+1, stripped)) else: internal_imports.append((i+1, stripped, line.split(stripped[0])[0])) print("--- Top-level imports ---") for lno, imp in imports: print(f"{lno}: {imp}") print("\n--- Internal imports ---") for lno, imp, indent in internal_imports: print(f"{lno}: [{len(indent)} spaces] {imp}") print("\n--- Duplicate top-level imports ---") seen = set() for lno, imp in imports: if imp in seen: print(f"Duplicate: {lno}: {imp}") seen.add(imp) print("\n--- Indentation check (first non-space character not at index 0 or multiple of 1) ---") # Actually, if it's 1-space indentation, any number of spaces is valid at the start? # No, if it's 1-space indentation, it means each level is 1 space. # So 0, 1, 2, 3... are all valid. # BUT if someone used 4 spaces for 1 level, that's wrong. # The only way to know is to see the context. # But the prompt says "Ensure the entire file uses exactly 1-space indentation." # This usually means convert 4-space to 1-space. # Let's just check for lines starting with 4 spaces that might be 1 level. # Or better, look for any line where indentation is not exactly 1 space more than parent. # That's hard without parsing. # Let's look for common 4-space patterns. four_spaces = 0 for i, line in enumerate(lines): if line.startswith(' ') and not line.startswith(' '): four_spaces += 1 print(f"Lines starting with exactly 4 spaces: {four_spaces}") if __name__ == "__main__": check_ai_client('src/ai_client.py')