Skip to content

Commit 243ab44

Browse files
style: apply ruff format to doctor.py and test_doctor.py
1 parent a87437f commit 243ab44

2 files changed

Lines changed: 28 additions & 50 deletions

File tree

concore_cli/commands/doctor.py

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"matplotlib": "pip install concore[demo]",
105105
}
106106

107+
107108
def _get_platform_key():
108109
"""Return 'posix' or 'windows' based on OS."""
109110
return "windows" if os.name == "nt" else "posix"
@@ -206,14 +207,14 @@ def doctor_check(console):
206207
passed += 1
207208
else:
208209
console.print(
209-
f" [red]✗[/red] Python {py_version} — "
210-
f"concore requires Python >= 3.9"
210+
f" [red]✗[/red] Python {py_version} — concore requires Python >= 3.9"
211211
)
212212
errors += 1
213213

214214
# concore installation
215215
try:
216216
from concore_cli import __version__
217+
217218
console.print(f" [green]✓[/green] concore {__version__} installed")
218219
passed += 1
219220
except ImportError:
@@ -226,9 +227,7 @@ def doctor_check(console):
226227
writable = os.access(str(concore_path), os.W_OK)
227228
status = "writable" if writable else "read-only"
228229
if writable:
229-
console.print(
230-
f" [green]✓[/green] CONCOREPATH: {concore_path} ({status})"
231-
)
230+
console.print(f" [green]✓[/green] CONCOREPATH: {concore_path} ({status})")
232231
passed += 1
233232
else:
234233
console.print(
@@ -285,9 +284,7 @@ def doctor_check(console):
285284
)
286285
warnings += 1
287286
else:
288-
console.print(
289-
f" [red]✗[/red] {tool_label} → Not found{hint_str}"
290-
)
287+
console.print(f" [red]✗[/red] {tool_label} → Not found{hint_str}")
291288
errors += 1
292289

293290
console.print()
@@ -310,18 +307,19 @@ def doctor_check(console):
310307
content = filepath.read_text().strip()
311308
if filename == "concore.tools":
312309
line_count = len(
313-
[ln for ln in content.splitlines()
314-
if ln.strip() and not ln.strip().startswith("#")]
310+
[
311+
ln
312+
for ln in content.splitlines()
313+
if ln.strip() and not ln.strip().startswith("#")
314+
]
315315
)
316316
console.print(
317317
f" [green]✓[/green] {filename} → "
318318
f"{line_count} tool path(s) configured"
319319
)
320320
elif filename == "concore.mcr":
321321
if os.path.exists(os.path.expanduser(content)):
322-
console.print(
323-
f" [green]✓[/green] {filename}{content}"
324-
)
322+
console.print(f" [green]✓[/green] {filename}{content}")
325323
passed += 1
326324
else:
327325
console.print(
@@ -331,27 +329,17 @@ def doctor_check(console):
331329
warnings += 1
332330
continue
333331
elif filename == "concore.sudo":
334-
console.print(
335-
f" [green]✓[/green] {filename}{content}"
336-
)
332+
console.print(f" [green]✓[/green] {filename}{content}")
337333
elif filename == "concore.repo":
338-
console.print(
339-
f" [green]✓[/green] {filename}{content}"
340-
)
334+
console.print(f" [green]✓[/green] {filename}{content}")
341335
else:
342-
console.print(
343-
f" [green]✓[/green] {filename} → Enabled"
344-
)
336+
console.print(f" [green]✓[/green] {filename} → Enabled")
345337
passed += 1
346338
except Exception:
347-
console.print(
348-
f" [yellow]![/yellow] {filename} → Could not read"
349-
)
339+
console.print(f" [yellow]![/yellow] {filename} → Could not read")
350340
warnings += 1
351341
else:
352-
console.print(
353-
f" [dim]—[/dim] {filename} → Not set ({description})"
354-
)
342+
console.print(f" [dim]—[/dim] {filename} → Not set ({description})")
355343

356344
# Build environment variable list from TOOL_DEFINITIONS config_keys
357345
env_vars = []
@@ -361,10 +349,7 @@ def doctor_check(console):
361349
env_vars.append("DOCKEREXE")
362350
env_set = [v for v in env_vars if os.environ.get(v)]
363351
if env_set:
364-
console.print(
365-
f" [green]✓[/green] Environment variables: "
366-
f"{', '.join(env_set)}"
367-
)
352+
console.print(f" [green]✓[/green] Environment variables: {', '.join(env_set)}")
368353
passed += 1
369354
else:
370355
console.print(" [dim]—[/dim] No concore environment variables set")
@@ -380,10 +365,7 @@ def doctor_check(console):
380365
console.print(f" [green]✓[/green] {pkg} {version}")
381366
passed += 1
382367
else:
383-
console.print(
384-
f" [red]✗[/red] {pkg} → Not installed "
385-
f"(pip install {pkg})"
386-
)
368+
console.print(f" [red]✗[/red] {pkg} → Not installed (pip install {pkg})")
387369
errors += 1
388370

389371
for pkg, install_hint in OPTIONAL_PACKAGES.items():
@@ -393,8 +375,7 @@ def doctor_check(console):
393375
passed += 1
394376
else:
395377
console.print(
396-
f" [yellow]![/yellow] {pkg} → Not installed "
397-
f"({install_hint})"
378+
f" [yellow]![/yellow] {pkg} → Not installed ({install_hint})"
398379
)
399380
warnings += 1
400381

tests/test_doctor.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ def test_doctor_shows_python_version(self):
4040
"""Doctor should show the current Python version."""
4141
result = self.runner.invoke(cli, ["doctor"])
4242
import platform
43+
4344
py_version = platform.python_version()
4445
self.assertIn(py_version, result.output)
4546

4647
def test_doctor_shows_concore_version(self):
4748
"""Doctor should detect and show concore version."""
4849
from concore_cli import __version__
50+
4951
result = self.runner.invoke(cli, ["doctor"])
5052
self.assertIn("concore", result.output)
5153
self.assertIn(__version__, result.output)
@@ -87,9 +89,7 @@ def test_detect_nonexistent_tool(self):
8789

8890
def test_detect_tool_tries_multiple_names(self):
8991
"""Should try all candidate names and return the first match."""
90-
path, name = _detect_tool(
91-
["nonexistent_tool_abc123", "python3", "python"]
92-
)
92+
path, name = _detect_tool(["nonexistent_tool_abc123", "python3", "python"])
9393
self.assertIsNotNone(path)
9494

9595
def test_detect_tool_empty_list(self):
@@ -165,9 +165,7 @@ def setUp(self):
165165
def tearDown(self):
166166
shutil.rmtree(self.temp_dir)
167167

168-
@patch(
169-
"concore_cli.commands.doctor._resolve_concore_path"
170-
)
168+
@patch("concore_cli.commands.doctor._resolve_concore_path")
171169
def test_doctor_with_concore_tools(self, mock_path):
172170
"""Doctor should detect and report concore.tools."""
173171
mock_path.return_value = Path(self.temp_dir)
@@ -176,14 +174,13 @@ def test_doctor_with_concore_tools(self, mock_path):
176174

177175
from rich.console import Console
178176
import io
177+
179178
console = Console(file=io.StringIO(), force_terminal=True)
180179
result = doctor_check(console)
181180
# Just verify it doesn't crash
182181
self.assertIsInstance(result, bool)
183182

184-
@patch(
185-
"concore_cli.commands.doctor._resolve_concore_path"
186-
)
183+
@patch("concore_cli.commands.doctor._resolve_concore_path")
187184
def test_doctor_with_concore_octave(self, mock_path):
188185
"""Doctor should detect concore.octave flag."""
189186
mock_path.return_value = Path(self.temp_dir)
@@ -192,13 +189,12 @@ def test_doctor_with_concore_octave(self, mock_path):
192189

193190
from rich.console import Console
194191
import io
192+
195193
console = Console(file=io.StringIO(), force_terminal=True)
196194
result = doctor_check(console)
197195
self.assertIsInstance(result, bool)
198196

199-
@patch(
200-
"concore_cli.commands.doctor._resolve_concore_path"
201-
)
197+
@patch("concore_cli.commands.doctor._resolve_concore_path")
202198
def test_doctor_with_concore_sudo(self, mock_path):
203199
"""Doctor should detect concore.sudo config."""
204200
mock_path.return_value = Path(self.temp_dir)
@@ -207,6 +203,7 @@ def test_doctor_with_concore_sudo(self, mock_path):
207203

208204
from rich.console import Console
209205
import io
206+
210207
console = Console(file=io.StringIO(), force_terminal=True)
211208
result = doctor_check(console)
212209
self.assertIsInstance(result, bool)

0 commit comments

Comments
 (0)