From eeedac7af76478cef5e81c0b833b011a7dbd57a6 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz <vlorentz@softwareheritage.org> Date: Thu, 8 Apr 2021 16:12:38 +0200 Subject: [PATCH] Remove accidental dependency of 'swh-identify' on swh-core Was added in be8f1a559d8209710a08ca48d93b7f513fa1c42f --- swh/model/cli.py | 7 ++++++- tox.ini | 11 ++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/swh/model/cli.py b/swh/model/cli.py index 8ac92507..312a0247 100644 --- a/swh/model/cli.py +++ b/swh/model/cli.py @@ -11,7 +11,12 @@ from typing import Dict, List, Optional # control import click -from swh.core.cli import swh as swh_cli_group +try: + from swh.core.cli import swh as swh_cli_group +except ImportError: + # stub so that swh-identify can be used when swh-core isn't installed + swh_cli_group = click # type: ignore + from swh.model.identifiers import CoreSWHID, ObjectType CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) diff --git a/tox.ini b/tox.ini index bffcdfaf..1ea702f9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=black,flake8,mypy,py3 +envlist=black,flake8,mypy,py3,identify [testenv] extras = @@ -12,6 +12,15 @@ commands = {envsitepackagesdir}/swh/model \ --cov-branch {posargs} +[testenv:identify] +# no 'extras = testing', as it would install swh-core; +# and this test is designed to check 'swh-identify' does not depend on swh-core. +extras = +deps = + -r requirements-test.txt +commands = + pytest {envsitepackagesdir}/swh/model/tests/test_cli.py + [testenv:black] skip_install = true deps = -- GitLab