mirror of
https://github.com/enpaul/tox-poetry-installer.git
synced 2025-01-15 08:43:29 +00:00
Update error handling to improve UX
Add discrete exception for version conflict vs not in lockfile errors Update to set tox venv to failed when conflict happens Update tox reporting for errors to use proper level
This commit is contained in:
parent
f20e434f2c
commit
c481b7b0bb
@ -60,8 +60,12 @@ class ToxPoetryInstallerException(Exception):
|
|||||||
"""Error while installing locked dependencies to the test environment"""
|
"""Error while installing locked dependencies to the test environment"""
|
||||||
|
|
||||||
|
|
||||||
class NoLockedDependencyError(ToxPoetryInstallerException):
|
class LockedDepVersionConflictError(ToxPoetryInstallerException):
|
||||||
"""Cannot install a package that is not in the lockfile"""
|
"""Locked dependencies cannot specify an alternate version for installation"""
|
||||||
|
|
||||||
|
|
||||||
|
class LockedDepNotFoundError(ToxPoetryInstallerException):
|
||||||
|
"""Locked dependency was not found in the lockfile"""
|
||||||
|
|
||||||
|
|
||||||
def _sort_env_deps(venv: ToxVirtualEnv) -> _SortedEnvDeps:
|
def _sort_env_deps(venv: ToxVirtualEnv) -> _SortedEnvDeps:
|
||||||
@ -172,12 +176,11 @@ def _find_transients(poetry: Poetry, dependency_name: str) -> List[PoetryPackage
|
|||||||
if any(
|
if any(
|
||||||
delimiter in dependency_name for delimiter in _PEP508_VERSION_DELIMITERS
|
delimiter in dependency_name for delimiter in _PEP508_VERSION_DELIMITERS
|
||||||
):
|
):
|
||||||
message = "cannot specify a version for a locked env dependency"
|
raise LockedDepVersionConflictError(
|
||||||
else:
|
f"Locked dependency '{dependency_name}' cannot include version specifier"
|
||||||
message = "no version of the env dependency was found in the current project's lockfile"
|
) from None
|
||||||
|
raise LockedDepNotFoundError(
|
||||||
raise NoLockedDependencyError(
|
f"No version of locked dependency '{dependency_name}' found in the project lockfile"
|
||||||
f"Cannot install env dependency '{dependency_name}': {message}"
|
|
||||||
) from None
|
) from None
|
||||||
|
|
||||||
|
|
||||||
@ -191,7 +194,12 @@ def _install_env_dependencies(venv: ToxVirtualEnv, poetry: Poetry):
|
|||||||
|
|
||||||
dependencies: List[PoetryPackage] = []
|
dependencies: List[PoetryPackage] = []
|
||||||
for dep in env_deps.locked_deps:
|
for dep in env_deps.locked_deps:
|
||||||
|
try:
|
||||||
dependencies += _find_transients(poetry, dep.name)
|
dependencies += _find_transients(poetry, dep.name)
|
||||||
|
except ToxPoetryInstallerException as err:
|
||||||
|
venv.status = "install-locked-deps-failed"
|
||||||
|
reporter.error(f"{_REPORTER_PREFIX} {err}")
|
||||||
|
raise err
|
||||||
|
|
||||||
reporter.verbosity1(
|
reporter.verbosity1(
|
||||||
f"{_REPORTER_PREFIX} identified {len(dependencies)} actual dependencies from {len(venv.envconfig.deps)} specified env dependencies"
|
f"{_REPORTER_PREFIX} identified {len(dependencies)} actual dependencies from {len(venv.envconfig.deps)} specified env dependencies"
|
||||||
|
Loading…
Reference in New Issue
Block a user