Skip to content

Commit a540ddd

Browse files
Remove import cycles (#1436)
1 parent 85241cc commit a540ddd

3 files changed

Lines changed: 7 additions & 16 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ reportCallInDefaultInitializer = false
214214
reportExplicitAny = false
215215
reportImplicitOverride = false
216216
reportImplicitStringConcatenation = false
217-
reportImportCycles = false
218217
reportInvalidAbstractMethod = false
219218
reportMissingParameterType = false
220219
reportMissingTypeArgument = false

src/usethis/_tool/impl/base/coverage_py.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,26 @@
88
from usethis._backend.uv.detect import is_uv_used
99
from usethis._console import how_print
1010
from usethis._tool.base import Tool
11+
from usethis._tool.heuristics import is_likely_used
1112
from usethis._tool.impl.spec.coverage_py import CoveragePyToolSpec
13+
from usethis._tool.impl.spec.pytest import PytestToolSpec
1214
from usethis._types.backend import BackendEnum
1315
from usethis._types.deps import Dependency
1416

1517

1618
class CoveragePyTool(CoveragePyToolSpec, Tool):
1719
@final
1820
def test_deps(self, *, unconditional: bool = False) -> list[Dependency]:
19-
from usethis._tool.impl.base.pytest import ( # to avoid circularity; # noqa: PLC0415
20-
PytestTool,
21-
)
22-
2321
deps = [Dependency(name="coverage", extras=frozenset({"toml"}))]
24-
if unconditional or PytestTool().is_used():
22+
if unconditional or is_likely_used(PytestToolSpec()):
2523
deps += [Dependency(name="pytest-cov")]
2624
return deps
2725

2826
@final
2927
def print_how_to_use(self) -> None:
30-
from usethis._tool.impl.base.pytest import ( # to avoid circularity; # noqa: PLC0415
31-
PytestTool,
32-
)
33-
3428
backend = get_backend()
3529

36-
if PytestTool().is_used():
30+
if is_likely_used(PytestToolSpec()):
3731
if backend is BackendEnum.uv and is_uv_used():
3832
how_print(
3933
f"Run 'uv run pytest --cov' to run your tests with {self.name}."

src/usethis/_tool/impl/base/pytest.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from usethis._integrations.environ.python import get_supported_minor_python_versions
1919
from usethis._python.version import PythonVersion
2020
from usethis._tool.base import Tool
21+
from usethis._tool.heuristics import is_likely_used
22+
from usethis._tool.impl.spec.coverage_py import CoveragePyToolSpec
2123
from usethis._tool.impl.spec.pytest import PytestToolSpec
2224
from usethis._types.backend import BackendEnum
2325
from usethis._types.deps import Dependency
@@ -31,12 +33,8 @@
3133
class PytestTool(PytestToolSpec, Tool):
3234
@final
3335
def test_deps(self, *, unconditional: bool = False) -> list[Dependency]:
34-
from usethis._tool.impl.base.coverage_py import ( # to avoid circularity; # noqa: PLC0415
35-
CoveragePyTool,
36-
)
37-
3836
deps = [Dependency(name="pytest")]
39-
if unconditional or CoveragePyTool().is_used():
37+
if unconditional or is_likely_used(CoveragePyToolSpec()):
4038
deps += [Dependency(name="pytest-cov")]
4139
return deps
4240

0 commit comments

Comments
 (0)