Skip to content

Commit 84099b9

Browse files
authored
Check for empty folders and raise with better error message (#216)
1 parent b07a57c commit 84099b9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

unidep/_dependencies_parsing.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,15 @@ def _extract_local_dependencies( # noqa: PLR0912
628628
" add a `requirements.yaml` or `pyproject.toml` file with"
629629
" `[tool.unidep]` in its directory.",
630630
)
631+
elif _is_empty_folder(abs_local):
632+
msg = (
633+
f"`{local_dependency}` in `local_dependencies` is not pip"
634+
" installable because it is an empty folder. Is it perhaps"
635+
" an uninitialized Git submodule? If so, initialize it with"
636+
" `git submodule update --init --recursive`. Otherwise,"
637+
" remove it from `local_dependencies`."
638+
)
639+
raise RuntimeError(msg) from None
631640
elif _is_empty_git_submodule(abs_local):
632641
# Extra check for empty Git submodules (common problem folks run into)
633642
msg = (
@@ -745,3 +754,8 @@ def _is_empty_git_submodule(path: Path) -> bool:
745754

746755
# Check if it's empty (apart from the .git file)
747756
return len(list(path.iterdir())) == 1 # Only .git should be present
757+
758+
759+
def _is_empty_folder(path: Path) -> bool:
760+
"""Checks if the given path is an empty folder."""
761+
return not any(path.iterdir())

0 commit comments

Comments
 (0)