from typing import List
from pathlib import Path


def remove_external_imports(imports: List[str], root: str) -> List[str]:
    """
    removes imports from external libraries.
    this is achieved by checking if the given import name contains the stem of the root directory
    (main directory of repo to analyze).
    :param imports: list of imports as strings.
    :param root: main directory to look for imports
    :return: list of imports (as strings) without external libraries.
    """
    return [match for match in imports if Path(root).stem in match]