Add handling of error when poetry.lock does not exist

Fixes #81
This commit is contained in:
Ethan Paul 2024-08-15 11:59:54 -04:00 committed by Ethan Paul
parent 506aae0ccd
commit 6837a64121
Signed by: enpaul
GPG Key ID: 07F53B438281D181
2 changed files with 15 additions and 4 deletions

View File

@ -11,6 +11,7 @@ All exceptions should inherit from the common base exception :exc:`ToxPoetryInst
+-- LockedDepNotFoundError +-- LockedDepNotFoundError
+-- ExtraNotFoundError +-- ExtraNotFoundError
+-- LockedDepsRequiredError +-- LockedDepsRequiredError
+-- LockfileParsingError
""" """
@ -41,3 +42,7 @@ class ExtraNotFoundError(ToxPoetryInstallerException):
class LockedDepsRequiredError(ToxPoetryInstallerException): class LockedDepsRequiredError(ToxPoetryInstallerException):
"""Environment cannot specify unlocked dependencies when locked dependencies are required""" """Environment cannot specify unlocked dependencies when locked dependencies are required"""
class LockfileParsingError(ToxPoetryInstallerException):
"""Failed to load or parse the Poetry lockfile"""

View File

@ -41,10 +41,16 @@ def tox_on_install(
virtualenv = convert_virtualenv(tox_env) virtualenv = convert_virtualenv(tox_env)
if not poetry.locker.is_fresh(): try:
logger.warning( if not poetry.locker.is_fresh():
f"The Poetry lock file is not up to date with the latest changes in {poetry.file}" logger.warning(
) f"The Poetry lock file is not up to date with the latest changes in {poetry.file}"
)
except FileNotFoundError as err:
logger.error(f"Could not parse lockfile: {err}")
raise exceptions.LockfileParsingError(
f"Could not parse lockfile: {err}"
) from err
try: try:
if tox_env.conf["require_locked_deps"] and tox_env.conf["deps"].lines(): if tox_env.conf["require_locked_deps"] and tox_env.conf["deps"].lines():