From e894a25d18360394951a6b3fd9803e33bf813eae Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Wed, 10 Feb 2021 00:06:33 -0500 Subject: [PATCH] Update logging messages to improve UX and output consistency --- tox_poetry_installer/constants.py | 2 +- tox_poetry_installer/hooks.py | 13 +++++++++---- tox_poetry_installer/installer.py | 4 ++-- tox_poetry_installer/utilities.py | 4 ++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tox_poetry_installer/constants.py b/tox_poetry_installer/constants.py index 2e7531e..ee739f9 100644 --- a/tox_poetry_installer/constants.py +++ b/tox_poetry_installer/constants.py @@ -19,7 +19,7 @@ PEP508_VERSION_DELIMITERS: Tuple[str, ...] = ("~=", "==", "!=", ">", "<") # Prefix all reporter messages should include to indicate that they came from this module in the # console output. -REPORTER_PREFIX: str = f"[{__about__.__title__}]:" +REPORTER_PREFIX: str = f"{__about__.__title__}:" # Semver compatible version of the current python platform version. Used for checking diff --git a/tox_poetry_installer/hooks.py b/tox_poetry_installer/hooks.py index 3b9bae4..6ddc742 100644 --- a/tox_poetry_installer/hooks.py +++ b/tox_poetry_installer/hooks.py @@ -84,6 +84,11 @@ def tox_testenv_install_deps(venv: ToxVirtualEnv, action: ToxAction) -> Optional f"{constants.REPORTER_PREFIX} Loaded project pyproject.toml from {poetry.file}" ) + if not poetry.locker.is_fresh(): + tox.reporter.warning( + f"The Poetry lock file is not up to date with the latest changes in {poetry.file}" + ) + try: if venv.envconfig.require_locked_deps and venv.envconfig.deps: raise exceptions.LockedDepsRequiredError( @@ -118,14 +123,14 @@ def tox_testenv_install_deps(venv: ToxVirtualEnv, action: ToxAction) -> Optional project_deps = utilities.find_project_deps( packages, poetry, venv.envconfig.extras ) + tox.reporter.verbosity1( + f"{constants.REPORTER_PREFIX} Identified {len(project_deps)} project dependencies to install to env" + ) else: project_deps = [] tox.reporter.verbosity1( - f"{constants.REPORTER_PREFIX} Skipping installation of project dependencies, env does not install project package" + f"{constants.REPORTER_PREFIX} Env does not install project package, skipping" ) - tox.reporter.verbosity1( - f"{constants.REPORTER_PREFIX} Identified {len(project_deps)} project dependencies to install to env" - ) except exceptions.ToxPoetryInstallerException as err: venv.status = err.__class__.__name__ tox.reporter.error(f"{constants.REPORTER_PREFIX} {err}") diff --git a/tox_poetry_installer/installer.py b/tox_poetry_installer/installer.py index 3f13f93..b45b910 100644 --- a/tox_poetry_installer/installer.py +++ b/tox_poetry_installer/installer.py @@ -42,12 +42,12 @@ def install( for dependency in packages: if dependency not in installed: - tox.reporter.verbosity1( + tox.reporter.verbosity2( f"{constants.REPORTER_PREFIX} Installing {dependency}" ) pip.install(dependency) installed.add(dependency) else: - tox.reporter.verbosity1( + tox.reporter.verbosity2( f"{constants.REPORTER_PREFIX} Already installed {dependency}, skipping" ) diff --git a/tox_poetry_installer/utilities.py b/tox_poetry_installer/utilities.py index c6da224..12952a2 100644 --- a/tox_poetry_installer/utilities.py +++ b/tox_poetry_installer/utilities.py @@ -111,13 +111,13 @@ def identify_transients( else: for index, dep in enumerate(package.requires): tox.reporter.verbosity2( - f"{constants.REPORTER_PREFIX} Processing dependency {index + 1}/{len(package.requires)} for {package}: {dep.name}" + f"{constants.REPORTER_PREFIX} Processing {package} dependency {index + 1}/{len(package.requires)}: {dep.name}" ) if dep.name not in searched: find_deps_of_deps(dep.name) else: tox.reporter.verbosity2( - f"{constants.REPORTER_PREFIX} Package with name '{dep.name}' has already been processed, skipping" + f"{constants.REPORTER_PREFIX} Skip {package}: already included for installation" ) tox.reporter.verbosity2( f"{constants.REPORTER_PREFIX} Including {package} for installation"