Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions components/polylith/commands/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ def used_by_as_bricks(bricks: dict, brick_deps: dict) -> dict:
}


def print_possible_invalid_bricks_interfaces_usage(
root: Path, ns: str, bricks: dict, bricks_deps: dict
) -> None:
flattened_bricks = set().union(*bricks.values())
bricks_with_deps = {b: bricks_deps[b] for b in flattened_bricks if b in bricks_deps}

for brick, brick_deps in bricks_with_deps.items():
used_bricks = used_by_as_bricks(bricks, brick_deps)

interface.report.print_brick_interface_invalid_usage(
root, ns, brick, used_bricks
)


def run(root: Path, ns: str, options: dict):
directory = options.get("directory")
brick = options.get("brick")
Expand Down Expand Up @@ -84,4 +98,8 @@ def run(root: Path, ns: str, options: dict):
return

deps.print_deps(bricks, imports, options)

if show_interface:
print_possible_invalid_bricks_interfaces_usage(root, ns, bricks, bricks_deps)

deps.print_bricks_with_circular_deps(circular_bricks, bricks)
12 changes: 9 additions & 3 deletions components/polylith/deps/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ def print_brick_deps(brick: str, bricks: dict, brick_deps: dict, options: dict):
output.save(table, options, f"deps_{brick}")


def print_brick_with_circular_deps(brick: str, deps: Set[str], bricks: dict) -> None:
def print_brick_with_circular_deps(
brick: str, deps: Set[str], bricks: dict, padding: Union[tuple, None] = None
) -> None:
bases = bricks["bases"]

console = Console(theme=theme.poly_theme)
Expand All @@ -158,9 +160,13 @@ def print_brick_with_circular_deps(brick: str, deps: Set[str], bricks: dict) ->
prefix = ":information:"
message = f"[{tag}]{brick}[/] [data]is used by[/] {others} [data]and also uses[/] {others}[data].[/]"

console.print(Padding(f"{prefix} {message}", (0, 0, 0, 1)), overflow="ellipsis")
pad = padding or (1, 0, 0, 1)
console.print(Padding(f"{prefix} {message}", pad), overflow="ellipsis")


def print_bricks_with_circular_deps(circular_bricks: dict, bricks: dict) -> None:
console = Console(theme=theme.poly_theme)
console.print()

for brick, deps in circular_bricks.items():
print_brick_with_circular_deps(brick, deps, bricks)
print_brick_with_circular_deps(brick, deps, bricks, (0, 0, 0, 1))
8 changes: 3 additions & 5 deletions components/polylith/interface/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from polylith.interface.usage import check_brick_interface_usage, unified_usages
from polylith.reporting import theme
from rich.console import Console
from rich.padding import Padding
from rich.table import Table


Expand All @@ -26,7 +27,7 @@ def print_brick_interface(root: Path, ns: str, brick: str, bricks: dict) -> None
*_ns, exposes = str.split(endpoint, ".")
table.add_row(f"[data]{exposes}[/]")

console.print(table, overflow="ellipsis")
console.print(Padding(table, (0, 0, 1, 0)), overflow="ellipsis")


def print_brick_interface_invalid_usage(
Expand All @@ -45,7 +46,6 @@ def print_brick_interface_invalid_usage(

console = Console(theme=theme.poly_theme)

table = Table(box=None)
tag = "base" if brick in bricks["bases"] else "comp"

for using_brick, usages in invalid_usage.items():
Expand All @@ -58,6 +58,4 @@ def print_brick_interface_invalid_usage(

message = f":information: {prefix}: {middle}."

table.add_row(f"{message}")

console.print(table, overflow="ellipsis")
console.print(Padding(f"{message}", (0, 0, 0, 1)), overflow="ellipsis")
2 changes: 1 addition & 1 deletion projects/poetry_polylith_plugin/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "poetry-polylith-plugin"
version = "1.50.0"
version = "1.51.0"
description = "A Poetry plugin that adds tooling support for the Polylith Architecture"
authors = ["David Vujic"]
homepage = "https://davidvujic.github.io/python-polylith-docs/"
Expand Down
2 changes: 1 addition & 1 deletion projects/polylith_cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "polylith-cli"
version = "1.44.0"
version = "1.45.0"
description = "Python tooling support for the Polylith Architecture"
authors = ['David Vujic']
homepage = "https://davidvujic.github.io/python-polylith-docs/"
Expand Down