From 05c5a26cc4cf9237fdc30f821bed8065a9f774a8 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Tue, 29 Sep 2020 18:58:42 -0400 Subject: [PATCH] Update non-poetry error handling to be more permissive Fixes #1 --- tox_poetry_installer.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tox_poetry_installer.py b/tox_poetry_installer.py index 268028b..75d1908 100644 --- a/tox_poetry_installer.py +++ b/tox_poetry_installer.py @@ -268,21 +268,16 @@ def tox_testenv_install_deps(venv: ToxVirtualEnv, action: ToxAction): try: poetry = PoetryFactory().create_poetry(venv.envconfig.config.toxinidir) - except RuntimeError as err: + except RuntimeError: # Support running the plugin when the current tox project does not use Poetry for its # environment/dependency management. # # ``RuntimeError`` is dangerous to blindly catch because it can be (and in Poetry's case, - # is) raised in many different places for different purposes. This check of the error - # content, while crude and potentially fragile, will hopefully prevent ``RuntimeError``s - # not caused by this specific condition to be re-raised as genuine errors. This may need - # tuning in the future. - if "[tool.poetry] section not found" in str(err): - reporter.verbosity1( - f"{_REPORTER_PREFIX} project does not use Poetry for env management, skipping installation of locked dependencies" - ) - return - raise err + # is) raised in many different places for different purposes. + reporter.verbosity1( + f"{_REPORTER_PREFIX} project does not use Poetry for env management, skipping installation of locked dependencies" + ) + return reporter.verbosity1( f"{_REPORTER_PREFIX} loaded project pyproject.toml from {poetry.file}"