tessl install tessl/pypi-tox-pyenv@1.1.0tox plugin that makes tox use `pyenv which` to find python executables
Agent Success
Agent success rate when using this tile
98%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.03x
Baseline
Agent success rate without this tile
95%
Build a Python utility that validates whether a command-line tool is installed with a specific version. The utility executes the tool's version command as a subprocess and verifies the output matches the expected version.
The utility should:
<tool_name> --version to retrieve version informationThe utility must handle three distinct error scenarios:
All custom exceptions should inherit from a base VersionCheckError exception.
@generates
class VersionCheckError(Exception):
"""Base exception for version checking errors."""
pass
class ToolNotFoundError(VersionCheckError):
"""Raised when the tool is not found in the system PATH."""
pass
class CommandFailedError(VersionCheckError):
"""Raised when the command execution fails with non-zero exit code."""
pass
class VersionMismatchError(VersionCheckError):
"""Raised when the actual version doesn't match the expected version."""
pass
def check_version(tool_name: str, expected_version: str) -> bool:
"""
Check if a tool's version matches the expected version.
Args:
tool_name: Name of the command-line tool to check
expected_version: Expected version string (e.g., "1.2.3")
Returns:
True if the version matches
Raises:
ToolNotFoundError: If the tool is not found in PATH
CommandFailedError: If the command exits with non-zero status
VersionMismatchError: If the version doesn't match
"""
passProvides subprocess execution and management capabilities for running external commands.