Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ reportCallInDefaultInitializer = false
reportExplicitAny = false
reportImplicitOverride = false
reportImplicitStringConcatenation = false
reportImportCycles = false
reportInvalidAbstractMethod = false
reportMissingParameterType = false
reportMissingTypeArgument = false
Expand Down
14 changes: 4 additions & 10 deletions src/usethis/_tool/impl/base/coverage_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,26 @@
from usethis._backend.uv.detect import is_uv_used
from usethis._console import how_print
from usethis._tool.base import Tool
from usethis._tool.heuristics import is_likely_used
from usethis._tool.impl.spec.coverage_py import CoveragePyToolSpec
from usethis._tool.impl.spec.pytest import PytestToolSpec
from usethis._types.backend import BackendEnum
from usethis._types.deps import Dependency


class CoveragePyTool(CoveragePyToolSpec, Tool):
@final
def test_deps(self, *, unconditional: bool = False) -> list[Dependency]:
from usethis._tool.impl.base.pytest import ( # to avoid circularity; # noqa: PLC0415
PytestTool,
)

deps = [Dependency(name="coverage", extras=frozenset({"toml"}))]
if unconditional or PytestTool().is_used():
if unconditional or is_likely_used(PytestToolSpec()):
deps += [Dependency(name="pytest-cov")]
return deps

@final
def print_how_to_use(self) -> None:
from usethis._tool.impl.base.pytest import ( # to avoid circularity; # noqa: PLC0415
PytestTool,
)

backend = get_backend()

if PytestTool().is_used():
if is_likely_used(PytestToolSpec()):
if backend is BackendEnum.uv and is_uv_used():
how_print(
f"Run 'uv run pytest --cov' to run your tests with {self.name}."
Expand Down
8 changes: 3 additions & 5 deletions src/usethis/_tool/impl/base/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from usethis._integrations.environ.python import get_supported_minor_python_versions
from usethis._python.version import PythonVersion
from usethis._tool.base import Tool
from usethis._tool.heuristics import is_likely_used
from usethis._tool.impl.spec.coverage_py import CoveragePyToolSpec
from usethis._tool.impl.spec.pytest import PytestToolSpec
from usethis._types.backend import BackendEnum
from usethis._types.deps import Dependency
Expand All @@ -31,12 +33,8 @@
class PytestTool(PytestToolSpec, Tool):
@final
def test_deps(self, *, unconditional: bool = False) -> list[Dependency]:
from usethis._tool.impl.base.coverage_py import ( # to avoid circularity; # noqa: PLC0415
CoveragePyTool,
)

deps = [Dependency(name="pytest")]
if unconditional or CoveragePyTool().is_used():
if unconditional or is_likely_used(CoveragePyToolSpec()):
deps += [Dependency(name="pytest-cov")]
return deps

Expand Down
Loading