Update require_poetry option to be config option rather than runtime

Add deprecation warning for future removal of runtime require_poetry option
This commit is contained in:
Ethan Paul 2021-04-19 23:11:04 -04:00
parent 1e04edef69
commit c8d7009200
No known key found for this signature in database
GPG Key ID: D0E2CBF1245E92BF

View File

@ -56,6 +56,13 @@ def tox_addoption(parser: ToxParser):
help="Require all dependencies in the environment be installed using the Poetry lockfile",
)
parser.add_testenv_attribute(
name="require_poetry",
type="bool",
default=False,
help="Trigger a failure if Poetry is not available to Tox",
)
parser.add_testenv_attribute(
name="locked_deps",
type="line-list",
@ -75,12 +82,18 @@ def tox_testenv_install_deps(venv: ToxVirtualEnv, action: ToxAction) -> Optional
:param action: Tox action object
"""
if venv.envconfig.config.option.require_poetry:
logger.warning(
"DEPRECATION WARNING: The '--require-poetry' runtime option is deprecated and will be "
"removed in version 1.0.0. Please update test environments that require Poetry to "
"set the 'require_poetry = true' option in tox.ini"
)
try:
poetry = utilities.check_preconditions(venv, action)
except exceptions.SkipEnvironment as err:
if (
isinstance(err, exceptions.PoetryNotInstalledError)
and venv.envconfig.config.option.require_poetry
if isinstance(err, exceptions.PoetryNotInstalledError) and (
venv.envconfig.config.option.require_poetry or venv.envconfig.require_poetry
):
venv.status = err.__class__.__name__
logger.error(str(err))