File size: 804 Bytes
71c3fce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
import re

PROJECT_ROOT = "."  # Change this if your root is not the current folder

matches = []

for dirpath, _, filenames in os.walk(PROJECT_ROOT):
    for filename in filenames:
        if filename.endswith(".py"):
            filepath = os.path.join(dirpath, filename)
            with open(filepath, encoding="utf-8") as f:
                for lineno, line in enumerate(f, 1):
                    if re.match(r"\s*from\s+\.+", line):
                        matches.append((filepath, lineno, line.strip()))

# Print results
if matches:
    print("\n⚠️ Relative imports found:\n")
    for filepath, lineno, line in matches:
        print(f"{filepath}:{lineno}: {line}")
    print(f"\nTotal: {len(matches)} relative imports detected.")
else:
    print("✅ No relative imports found.")