Skip to content

Commit 49b7130

Browse files
authored
fix(poly check, poly libs): discover libraries by comparing normalized names (#238)
* fix(poly check, poly libs): library discovery comparing with normalized names (i.e. lowercase) * bump Poetry plugin to 1.25.1 * bump CLI to 1.12.1
1 parent 1784d91 commit 49b7130

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

components/polylith/alias/core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ def parse(aliases: List[str]) -> Dict[str, List[str]]:
1616

1717

1818
def pick(aliases: Dict[str, List[str]], keys: Set) -> Set:
19-
matrix = [v for k, v in aliases.items() if k in keys]
19+
normalized_keys = {str.lower(k) for k in keys}
20+
21+
matrix = [v for k, v in aliases.items() if str.lower(k) in normalized_keys]
2022

2123
flattened: List = sum(matrix, [])
2224

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.25.0"
3+
version = "1.25.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.12.0"
3+
version = "1.12.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/alias/test_alias.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ def test_pick_aliases_by_keys():
4444
assert res == {"cv2", "mpl_toolkits", "matplotlib"}
4545

4646

47+
def test_pick_aliases_by_case_insensitive_keys():
48+
aliases = {
49+
"opencv-python": ["cv2"],
50+
"PyJWT": ["jwt"],
51+
"Jinja2": ["jinja2"],
52+
"PyYAML": ["_yaml", "yaml"],
53+
}
54+
55+
keys = {"one", "two", "jinja2", "pyyaml", "opencv-python", "pyjwt"}
56+
57+
res = alias.pick(aliases, keys)
58+
59+
assert res == {"cv2", "jinja2", "jwt", "_yaml", "yaml"}
60+
61+
4762
def test_pick_empty_alias_by_keys():
4863
aliases = {}
4964

0 commit comments

Comments
 (0)