from pathlib import Path
import ast
from typing import List, Tuple, Set

def find_python_files(directory: str) -> List[Path]:
    """
    Recursively find all Python files in a directory.
    """
    return [file for file in Path(directory).rglob('*.py')]

def check_syntax(file_path: str) -> bool:
    """
    Check if a Python file has syntax errors.
    """
    with open(file_path, 'r', encoding='utf-8') as file:
        try:
            ast.parse(file.read(), filename=file_path)
        except SyntaxError:
            return False
    return True

def extract_imports_and_usage(file_path: str) -> Tuple[Set[str], Set[str]]:
    """
    Extract imports and unused imports from a Python file.
    """
    with open(file_path, 'r', encoding='utf-8') as file:
        tree = ast.parse(file.read(), filename=file_path)

    imports = set()
    used_imports = set()

    for node in ast.walk(tree):
        if isinstance(node, ast.Import):
            for alias in node.names:
                imports.add(alias.name.split('.')[0])
        elif isinstance(node, ast.ImportFrom):
            if node.module:
                imports.add(node.module)
        elif isinstance(node, ast.Name):
            used_imports.add(node.id)

    unused_imports = imports - used_imports
    return imports, unused_imports