Skip to content

Commit 6dfa0ac

Browse files
authored
fix(poly sync): sort by type and then alphabetically for Poetry projects (#458)
* fix(poly sync): sort by brick type and then alphabetically for Poetry packages * bump CLI to 1.49.1 * bump Poetry plugin to 1.53.1
1 parent f323b5c commit 6dfa0ac

4 files changed

Lines changed: 10 additions & 11 deletions

File tree

components/polylith/sync/update.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,9 @@ def to_sorted_packages(packages: List[dict]) -> List[dict]:
8181
sorted_by_brick_type = sorted(packages, key=sort_fn_by_from)
8282
grouped = itertools.groupby(sorted_by_brick_type, key=sort_fn_by_from)
8383

84-
groups = [list(g) for _k, g in grouped]
85-
flattened: List[dict] = reduce(operator.iadd, groups, [])
84+
groups = [sorted(g, key=sort_fn_by_include) for _k, g in grouped]
8685

87-
return sorted(flattened, key=sort_fn_by_include)
86+
return reduce(operator.iadd, groups, [])
8887

8988

9089
def generate_updated_poetry_project(data: TOMLDocument, packages: List[dict]) -> str:

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.53.0"
3+
version = "1.53.1"
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/"

projects/polylith_cli/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 = "polylith-cli"
3-
version = "1.49.0"
3+
version = "1.49.1"
44
description = "Python tooling support for the Polylith Architecture"
55
authors = ['David Vujic']
66
homepage = "https://davidvujic.github.io/python-polylith-docs/"

test/components/polylith/sync/test_update.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ def test_bricks_to_pyproject_packages():
7878
}
7979

8080
unsorted_packages = [
81-
{"include": "hello/c", "from": "components"},
82-
{"include": "hello/a", "from": "bases"},
8381
{"include": "hello/b", "from": "components"},
82+
{"include": "hello/x", "from": "bases"},
83+
{"include": "hello/a", "from": "components"},
8484
]
8585

8686
expected_sorted_pep621_bricks = {
8787
"bases/hello/first": "hello/first",
88-
"bases/hello/a": "hello/a",
88+
"bases/hello/x": "hello/x",
89+
"components/hello/a": "hello/a",
8990
"components/hello/b": "hello/b",
90-
"components/hello/c": "hello/c",
9191
}
9292

9393
poetry_project_data = """\
@@ -140,9 +140,9 @@ def test_generate_updated_poetry_project_with_the_bricks_to_update_sorted():
140140

141141
expected = [
142142
{"include": "hello/first", "from": "bases"},
143-
{"include": "hello/a", "from": "bases"},
143+
{"include": "hello/x", "from": "bases"},
144+
{"include": "hello/a", "from": "components"},
144145
{"include": "hello/b", "from": "components"},
145-
{"include": "hello/c", "from": "components"},
146146
]
147147

148148
updated = update.generate_updated_project(data, unsorted_packages)

0 commit comments

Comments
 (0)