src/nitpick/project.py
def find_root(current_dir: Optional[PathOrStr] = None) -> Path:
    """Find the root dir of the Python project (the one that has one of the ``ROOT_FILES``).

    Start from the current working dir.
    """
    root_dirs: Set[Path] = set()
    seen: Set[Path] = set()

    starting_dir = find_starting_dir(current_dir or Path.cwd())
    while starting_dir:  # pragma: no cover # starting_dir will always have a value on the first run
        logger.debug(f"Climbing dir: {starting_dir}")
        project_files = climb_directory_tree(starting_dir, ROOT_FILES)
        if project_files and project_files & seen:
            break
        seen.update(project_files)
        logger.debug(f"Project files seen: {str(project_files)}")

        if not project_files:
            # If none of the root files were found, try again with manage.py.
            # On Django projects, it can be in another dir inside the root dir.
            project_files = climb_directory_tree(starting_dir, [MANAGE_PY])
            if not project_files or project_files & seen:
                break
            seen.update(project_files)
            logger.debug(f"Django project files seen: {project_files}")

        for found in project_files:
            root_dirs.add(found.parent)
        logger.debug(f"Root dirs: {str(root_dirs)}")

        # Climb up one directory to search for more project files
        starting_dir = starting_dir.parent

    if not root_dirs:
        logger.error(f"No files found while climbing directory tree from {starting_dir}")
        raise QuitComplainingError(Reporter().make_fuss(ProjectViolations.NO_ROOT_DIR))

    # If multiple roots are found, get the top one (grandparent dir)
    top_dir = sorted(root_dirs)[0]
    logger.debug(f"Top root dir found: {top_dir}")
    return top_dir
Find the root dir of the Python project (the one that has one of the ``ROOT_FILES``).

    Start from the current working dir.
    
Find the root dir of the Python project (the one that has one of the ``ROOT_FILES``).
Start from the current working dir.
Find the root dir of the Python project ( the one that has one of the ` ` ROOT_FILES ` ` ) . Start from the current working dir .
def find_root(current_dir: Optional[PathOrStr] = None) -> Path:
    root_dirs: Set[Path] = set()
    seen: Set[Path] = set()
    starting_dir = find_starting_dir(current_dir or Path.cwd())
    while starting_dir:  
        logger.debug(f"Climbing dir: {starting_dir}")
        project_files = climb_directory_tree(starting_dir, ROOT_FILES)
        if project_files and project_files & seen:
            break
        seen.update(project_files)
        logger.debug(f"Project files seen: {str(project_files)}")
        if not project_files:
            project_files = climb_directory_tree(starting_dir, [MANAGE_PY])
            if not project_files or project_files & seen:
                break
            seen.update(project_files)
            logger.debug(f"Django project files seen: {project_files}")
        for found in project_files:
            root_dirs.add(found.parent)
        logger.debug(f"Root dirs: {str(root_dirs)}")
        starting_dir = starting_dir.parent
    if not root_dirs:
        logger.error(f"No files found while climbing directory tree from {starting_dir}")
        raise QuitComplainingError(Reporter().make_fuss(ProjectViolations.NO_ROOT_DIR))
    top_dir = sorted(root_dirs)[0]
    logger.debug(f"Top root dir found: {top_dir}")
    return top_dir
def find_root ( current_dir : Optional [ PathOrStr ] = None ) -> Path : root_dirs : Set [ Path ] = set ( ) seen : Set [ Path ] = set ( ) starting_dir = find_starting_dir ( current_dir or Path . cwd ( ) ) while starting_dir : logger . debug ( f"Climbing dir: {starting_dir}" ) project_files = climb_directory_tree ( starting_dir , ROOT_FILES ) if project_files and project_files & seen : break seen . update ( project_files ) logger . debug ( f"Project files seen: {str(project_files)}" ) if not project_files : project_files = climb_directory_tree ( starting_dir , [ MANAGE_PY ] ) if not project_files or project_files & seen : break seen . update ( project_files ) logger . debug ( f"Django project files seen: {project_files}" ) for found in project_files : root_dirs . add ( found . parent ) logger . debug ( f"Root dirs: {str(root_dirs)}" ) starting_dir = starting_dir . parent if not root_dirs : logger . error ( f"No files found while climbing directory tree from {starting_dir}" ) raise QuitComplainingError ( Reporter ( ) . make_fuss ( ProjectViolations . NO_ROOT_DIR ) ) top_dir = sorted ( root_dirs ) [ 0 ] logger . debug ( f"Top root dir found: {top_dir}" ) return top_dir
Find the root dir of the Python project (the one that has one of the ``ROOT_FILES``).
Find the root dir of the Python project ( the one that has one of the ` ` ROOT_FILES ` ` ) .
"""Find the root dir of the Python project (the one that has one of the ``ROOT_FILES``).

    Start from the current working dir.
    """ # pragma: no cover # starting_dir will always have a value on the first run # If none of the root files were found, try again with manage.py. # On Django projects, it can be in another dir inside the root dir. # Climb up one directory to search for more project files # If multiple roots are found, get the top one (grandparent dir)
current_dir
Optional[PathOrStr]