Skip to content

Commit 5e4ae90

Browse files
authored
fix(poly check and poly sync): respect the --quiet flag (#110)
1 parent 7a178f6 commit 5e4ae90

4 files changed

Lines changed: 32 additions & 16 deletions

File tree

components/polylith/check/report.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ def print_brick_imports(brick_imports: dict) -> None:
2424
)
2525

2626

27-
def print_missing_deps(diff: Set[str], project_name: str) -> bool:
27+
def print_missing_deps(diff: Set[str], project_name: str) -> None:
2828
if not diff:
29-
return True
29+
return
3030

3131
console = Console(theme=theme.poly_theme)
3232

3333
missing = ", ".join(sorted(diff))
3434

3535
console.print(f":thinking_face: Cannot locate {missing} in {project_name}")
36-
return False
3736

3837

3938
def fetch_brick_imports(root: Path, ns: str, all_imports: dict) -> dict:
@@ -42,14 +41,12 @@ def fetch_brick_imports(root: Path, ns: str, all_imports: dict) -> dict:
4241
return collect.with_unknown_components(root, ns, extracted)
4342

4443

45-
def print_report(
44+
def create_report(
4645
root: Path,
4746
ns: str,
4847
project_data: dict,
4948
third_party_libs: Set,
50-
) -> Tuple[bool, dict, dict]:
51-
name = project_data["name"]
52-
49+
) -> Tuple[bool, dict]:
5350
bases = {b for b in project_data.get("bases", [])}
5451
components = {c for c in project_data.get("components", [])}
5552

@@ -70,9 +67,15 @@ def print_report(
7067
}
7168

7269
brick_diff = collect.imports_diff(brick_imports, list(bases), list(components))
73-
brick_result = print_missing_deps(brick_diff, name)
74-
7570
libs_diff = libs.report.calculate_diff(third_party_imports, third_party_libs)
76-
libs_result = print_missing_deps(libs_diff, name)
7771

78-
return all([brick_result, libs_result]), brick_imports, third_party_imports
72+
res = all([not brick_diff, not libs_diff])
73+
74+
report_details = {
75+
"brick_imports": brick_imports,
76+
"third_party_imports": third_party_imports,
77+
"brick_diff": brick_diff,
78+
"libs_diff": libs_diff,
79+
}
80+
81+
return res, report_details

components/polylith/poetry/commands/check.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,29 @@ def find_third_party_libs(self, path: Union[Path, None]) -> Set:
2222

2323
def print_report(self, root: Path, ns: str, project_data: dict) -> bool:
2424
is_verbose = self.option("verbose")
25+
is_quiet = self.option("quiet")
26+
2527
path = project_data["path"]
2628
name = project_data["name"]
2729

2830
try:
2931
third_party_libs = self.find_third_party_libs(path)
30-
res, brick_imports, third_party_imports = check.report.print_report(
32+
res, details = check.report.create_report(
3133
root,
3234
ns,
3335
project_data,
3436
third_party_libs,
3537
)
3638

39+
if is_quiet:
40+
return res
41+
42+
check.report.print_missing_deps(details["brick_diff"], name)
43+
check.report.print_missing_deps(details["libs_diff"], name)
44+
3745
if is_verbose:
38-
check.report.print_brick_imports(brick_imports)
39-
check.report.print_brick_imports(third_party_imports)
46+
check.report.print_brick_imports(details["brick_imports"])
47+
check.report.print_brick_imports(details["third_party_imports"])
4048

4149
return res
4250
except ValueError as e:

components/polylith/poetry/commands/sync.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def filter_projects_data(self, all_projects_data: List[dict]) -> List[dict]:
2626

2727
def handle(self) -> int:
2828
is_verbose = self.option("verbose")
29+
is_quiet = self.option("quiet")
2930

3031
root = repo.find_workspace_root(Path.cwd())
3132

@@ -49,9 +50,13 @@ def handle(self) -> int:
4950
]
5051

5152
for diff in diffs:
52-
sync.report.print_summary(diff)
5353
sync.update_project(root, ns, diff)
5454

55+
if is_quiet:
56+
continue
57+
58+
sync.report.print_summary(diff)
59+
5560
if is_verbose:
5661
sync.report.print_brick_imports(diff)
5762

projects/poetry_polylith_plugin/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "poetry-polylith-plugin"
3-
version = "1.8.2"
3+
version = "1.8.3"
44
description = "A Poetry plugin that adds tooling support for the Polylith Architecture"
55
authors = ["David Vujic"]
66
homepage = "https://davidvujic.github.io/python-polylith-docs/"

0 commit comments

Comments
 (0)