Skip to content

Commit 0b2b615

Browse files
committed
fix: do not display unnecesary info with --json
1 parent 083ebb4 commit 0b2b615

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/twyn/main.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -246,27 +246,26 @@ def _analyze_dependencies(
246246
def _get_dependencies_list(
247247
normalized_dependencies: set[str], show_progress_bar: bool, dependency_file: str | None = None
248248
) -> Iterable[str]:
249-
"""Determine if the progress bar will be showed or not. It returns an iterable of all the dependencies to analyze."""
249+
"""Return an iterable of dependencies, optionally with progress tracking."""
250+
if not show_progress_bar:
251+
return normalized_dependencies
252+
250253
try:
251254
from rich.progress import track # noqa: PLC0415
252255

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

256259
echo(style(f"Reading file {dependency_file}", fg="green"), color=True)
257-
return (
258-
track(normalized_dependencies, description="Processing...")
259-
if show_progress_bar
260-
else normalized_dependencies
261-
)
260+
261+
return track(normalized_dependencies, description="Processing...")
262+
262263
except ModuleNotFoundError as e:
263-
if show_progress_bar:
264-
raise InvalidArgumentsError(
265-
"Cannot show progress bar because `rich` and `click` dependencies are not installed. "
266-
"It is only meant to be shown when running `twyn` as a cli tool. "
267-
"If this is you case, install all the dependencies with `pip install twyn[cli]`. "
268-
) from e
269-
return normalized_dependencies
264+
raise InvalidArgumentsError(
265+
"Cannot show progress bar because `rich` and `click` dependencies are not installed. "
266+
"It is only meant to be shown when running `twyn` as a cli tool. "
267+
"If this is you case, install all the dependencies with `pip install twyn[cli]`. "
268+
) from e
270269

271270

272271
def _get_selector_method(selector_method: str) -> SelectorMethod:

0 commit comments

Comments
 (0)