Refactor code style and improve documentation
- Standardized string quotes to single quotes across all files. - Added docstrings to several functions and classes for better clarity. - Updated mypy configuration in pyproject.toml for enhanced type checking. - Ignored specific linting rules for test files in ruff configuration. - Improved error messages in exception handling for better user feedback. - Cleaned up code formatting and structure for consistency.
This commit is contained in:
+17
-14
@@ -12,39 +12,42 @@ def test_find_supported_js_runtimes_prefers_deno(
|
||||
) -> None:
|
||||
monkeypatch.setattr(
|
||||
runtime,
|
||||
"which",
|
||||
lambda executable: "/usr/bin/deno" if executable == "deno" else None,
|
||||
'which',
|
||||
lambda executable: '/usr/bin/deno' if executable == 'deno' else None,
|
||||
)
|
||||
|
||||
runtimes = runtime.find_supported_js_runtimes()
|
||||
|
||||
assert runtimes == {"deno": {"path": "/usr/bin/deno"}}
|
||||
assert runtimes == {'deno': {'path': '/usr/bin/deno'}}
|
||||
|
||||
|
||||
def test_find_supported_js_runtimes_uses_best_supported_node(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
first_node = tmp_path / ".nvm" / "versions" / "node" / "v22.1.0" / "bin" / "node"
|
||||
second_node = tmp_path / ".nvm" / "versions" / "node" / "v22.9.0" / "bin" / "node"
|
||||
first_node = tmp_path / '.nvm' / 'versions' / 'node' / 'v22.1.0' / 'bin' / 'node'
|
||||
second_node = tmp_path / '.nvm' / 'versions' / 'node' / 'v22.9.0' / 'bin' / 'node'
|
||||
second_node.parent.mkdir(parents=True)
|
||||
first_node.parent.mkdir(parents=True)
|
||||
first_node.write_text("", encoding="utf-8")
|
||||
second_node.write_text("", encoding="utf-8")
|
||||
first_node.write_text('', encoding='utf-8')
|
||||
second_node.write_text('', encoding='utf-8')
|
||||
|
||||
monkeypatch.setattr(runtime, "which", lambda executable: None)
|
||||
monkeypatch.setattr(Path, "home", lambda: tmp_path)
|
||||
def fake_which(_executable: str) -> None:
|
||||
return None
|
||||
|
||||
monkeypatch.setattr(runtime, 'which', fake_which)
|
||||
monkeypatch.setattr(Path, 'home', lambda: tmp_path)
|
||||
monkeypatch.setattr(
|
||||
runtime,
|
||||
"_probe_executable_version",
|
||||
lambda executable: (22, 9, 0) if executable.endswith("v22.9.0/bin/node") else (22, 1, 0),
|
||||
'_probe_executable_version',
|
||||
lambda executable: (22, 9, 0) if executable.endswith('v22.9.0/bin/node') else (22, 1, 0),
|
||||
)
|
||||
|
||||
runtimes = runtime.find_supported_js_runtimes()
|
||||
|
||||
assert runtimes == {"node": {"path": str(second_node.resolve())}}
|
||||
assert runtimes == {'node': {'path': str(second_node.resolve())}}
|
||||
|
||||
|
||||
def test_parse_semver_handles_prefixed_versions() -> None:
|
||||
assert runtime._parse_semver("v22.12.1") == (22, 12, 1)
|
||||
assert runtime._parse_semver("node") is None
|
||||
assert runtime._parse_semver('v22.12.1') == (22, 12, 1)
|
||||
assert runtime._parse_semver('node') is None
|
||||
|
||||
Reference in New Issue
Block a user