Skip to content

Commit 2f530b9

Browse files
Ensure Import Linter is added via use_ci_bitbucket (#988)
1 parent 65180dc commit 2f530b9

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/usethis/_core/ci.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
)
88
from usethis._tool.impl.codespell import CodespellTool
99
from usethis._tool.impl.deptry import DeptryTool
10+
from usethis._tool.impl.import_linter import ImportLinterTool
1011
from usethis._tool.impl.pre_commit import PreCommitTool
1112
from usethis._tool.impl.pyproject_fmt import PyprojectFmtTool
1213
from usethis._tool.impl.pytest import PytestTool
@@ -23,13 +24,15 @@ def use_ci_bitbucket(*, remove: bool = False, how: bool = False) -> None:
2324
use_pytest = PytestTool().is_used()
2425
use_ruff = RuffTool().is_used()
2526
use_deptry = DeptryTool().is_used()
27+
use_import_linter = ImportLinterTool().is_used()
2628
use_pyproject_fmt = PyprojectFmtTool().is_used()
2729
use_codespell = CodespellTool().is_used()
2830
use_any_tool = (
2931
use_pre_commit
3032
or use_pytest
3133
or use_ruff
3234
or use_deptry
35+
or use_import_linter
3336
or use_pyproject_fmt
3437
or use_codespell
3538
)
@@ -39,11 +42,12 @@ def use_ci_bitbucket(*, remove: bool = False, how: bool = False) -> None:
3942
if use_pre_commit:
4043
PreCommitTool().update_bitbucket_steps()
4144
else:
42-
# This order should match the canonical order in the function which add
45+
# This order should match the canonical order in the function which adds
4346
# steps
4447
PyprojectFmtTool().update_bitbucket_steps()
4548
RuffTool().update_bitbucket_steps()
4649
DeptryTool().update_bitbucket_steps()
50+
ImportLinterTool().update_bitbucket_steps()
4751
CodespellTool().update_bitbucket_steps()
4852

4953
PytestTool().update_bitbucket_steps()

src/usethis/_integrations/ci/bitbucket/steps.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def _add_step_in_default_via_doc(
166166
"Run Ruff",
167167
"Run Ruff Formatter",
168168
"Run deptry",
169+
"Run Import Linter",
169170
"Run Codespell",
170171
*[f"Test on 3.{maj_version}" for maj_version in maj_versions],
171172
]

tests/usethis/_core/test_core_tool.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@ def test_subset_hook_names(self, tmp_path: Path):
5353
assert hook_name in _HOOK_ORDER
5454

5555

56+
class TestAllBitbucketCompatibleSteps:
57+
def test_names_regression(self, tmp_path: Path):
58+
# See https://github.com/usethis-python/usethis-python/issues/981
59+
with change_cwd(tmp_path), files_manager():
60+
names = set()
61+
for tool in ALL_TOOLS:
62+
steps = tool.get_bitbucket_steps()
63+
if steps:
64+
names.add(tool.name)
65+
66+
# Until https://github.com/usethis-python/usethis-python/issues/981 is resolved,
67+
# if this test changes, make sure to update `use_ci_bitbucket`.
68+
assert names == {
69+
"Codespell",
70+
"deptry",
71+
"Import Linter",
72+
"pre-commit",
73+
"pyproject-fmt",
74+
"pytest",
75+
"Ruff",
76+
}
77+
78+
5679
class TestCodespell:
5780
class TestAdd:
5881
@pytest.mark.usefixtures("_vary_network_conn")

0 commit comments

Comments
 (0)