Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/twyn/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,27 +246,26 @@ def _analyze_dependencies(
def _get_dependencies_list(
normalized_dependencies: set[str], show_progress_bar: bool, dependency_file: str | None = None
) -> Iterable[str]:
"""Determine if the progress bar will be showed or not. It returns an iterable of all the dependencies to analyze."""
"""Return an iterable of dependencies, optionally with progress tracking."""
if not show_progress_bar:
return normalized_dependencies

try:
from rich.progress import track # noqa: PLC0415

if dependency_file:
from click import echo, style # noqa: PLC0415

echo(style(f"Reading file {dependency_file}", fg="green"), color=True)
return (
track(normalized_dependencies, description="Processing...")
if show_progress_bar
else normalized_dependencies
)

return track(normalized_dependencies, description="Processing...")

except ModuleNotFoundError as e:
if show_progress_bar:
raise InvalidArgumentsError(
"Cannot show progress bar because `rich` and `click` dependencies are not installed. "
"It is only meant to be shown when running `twyn` as a cli tool. "
"If this is you case, install all the dependencies with `pip install twyn[cli]`. "
) from e
return normalized_dependencies
raise InvalidArgumentsError(
"Cannot show progress bar because `rich` and `click` dependencies are not installed. "
"It is only meant to be shown when running `twyn` as a cli tool. "
"If this is you case, install all the dependencies with `pip install twyn[cli]`. "
) from e


def _get_selector_method(selector_method: str) -> SelectorMethod:
Expand Down
Loading