Skip to content

Commit 44d6cd5

Browse files
resolves the conversations
1 parent cbd41da commit 44d6cd5

File tree

2 files changed

+13
-33
lines changed

2 files changed

+13
-33
lines changed

exasol/toolbox/nox/_dependencies_check.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ def dependency_check(session: Session) -> None:
1616
content = Path(PROJECT_CONFIG.root, "pyproject.toml").read_text()
1717
dependencies = Dependencies(content).parse()
1818
console = rich.console.Console()
19-
illegal = dependencies.illegal()
20-
report_illegal(illegal, console)
21-
if illegal:
19+
if illegal := dependencies.illegal:
20+
report_illegal(illegal, console)
2221
sys.exit(1)
2322

2423

@@ -66,19 +65,17 @@ def extract_dependencies(section) -> List[str]:
6665
self.illegal_dict = illegal
6766
return self
6867

68+
@property
6969
def illegal(self) -> Dict[str, List[str]]:
7070
return self.illegal_dict
7171

7272

7373
def report_illegal(illegal: Dict[str, List[str]], console: rich.console.Console):
74-
if illegal:
75-
count = sum(len(deps) for deps in illegal.values())
76-
suffix = "y" if count == 1 else "ies"
77-
console.print(f"{count} illegal dependenc{suffix}\n", style="red")
78-
for section, dependencies in illegal.items():
79-
console.print(f"\\[{section}]", style="red")
80-
for dependency in dependencies:
81-
console.print(dependency, style="red")
82-
console.print("")
83-
else:
84-
console.print("Success: All dependencies refer to explicit pipy releases.", style="green")
74+
count = sum(len(deps) for deps in illegal.values())
75+
suffix = "y" if count == 1 else "ies"
76+
console.print(f"{count} illegal dependenc{suffix}\n", style="red")
77+
for section, dependencies in illegal.items():
78+
console.print(f"\\[{section}]", style="red")
79+
for dependency in dependencies:
80+
console.print(dependency, style="red")
81+
console.print("")

test/unit/dependencies_check_test.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
)
9797
def test_dependency_check_parse(toml, expected):
9898
dependencies = Dependencies(toml).parse()
99-
assert dependencies.illegal() == expected
99+
assert dependencies.illegal == expected
100100

101101

102102
@pytest.mark.parametrize(
@@ -136,29 +136,12 @@ def test_dependency_check_parse(toml, expected):
136136
example-path1 = {'path': '../my-package/dist/my-package-0.1.0.tar.gz'}
137137
example-path2 = {'path': '../my-package/dist/my-package-0.2.0.tar.gz'}
138138
139-
"""
140-
),
141-
(
142-
"""
143-
[tool.poetry.dependencies]
144-
python = "^3.8"
145-
146-
[tool.poetry.dev.dependencies]
147-
nox = ">=2022.8.7"
148-
149-
[tool.poetry.group.test.dependencies]
150-
sphinx = ">=5.3,<8"
151-
152-
[tool.poetry.group.dev.dependencies]
153-
pytest = ">=7.2.2,<9"
154-
""",
155-
"""Success: All dependencies refer to explicit pipy releases.
156139
"""
157140
),
158141
]
159142
)
160143
def test_dependencies_check_report(toml, expected, capsys):
161144
console = rich.console.Console()
162145
dependencies = Dependencies(toml).parse()
163-
report_illegal(dependencies.illegal(), console)
146+
report_illegal(dependencies.illegal, console)
164147
assert capsys.readouterr().out == expected

0 commit comments

Comments
 (0)