33from pathlib import Path
44from typing import TYPE_CHECKING
55
6- from usethis ._ci import (
7- is_bitbucket_used ,
8- remove_bitbucket_pytest_steps ,
9- update_bitbucket_pytest_steps ,
10- )
116from usethis ._config import usethis_config
127from usethis ._console import tick_print
13- from usethis ._integrations .ci .bitbucket .steps import (
14- add_bitbucket_steps_in_default ,
15- remove_bitbucket_steps_from_default ,
16- )
8+ from usethis ._integrations .ci .bitbucket .used import is_bitbucket_used
179from usethis ._integrations .file .pyproject_toml .valid import ensure_pyproject_validity
1810from usethis ._integrations .pre_commit .core import (
1911 install_pre_commit_hooks ,
@@ -52,15 +44,14 @@ def use_codespell(*, remove: bool = False) -> None:
5244 if not remove :
5345 if not PreCommitTool ().is_used ():
5446 tool .add_dev_deps ()
55- if is_bitbucket_used ():
56- add_bitbucket_steps_in_default (tool .get_bitbucket_steps ())
47+ tool .update_bitbucket_steps ()
5748 else :
5849 tool .add_pre_commit_repo_configs ()
5950
6051 tool .add_configs ()
6152 tool .print_how_to_use ()
6253 else :
63- remove_bitbucket_steps_from_default ( tool .get_bitbucket_steps () )
54+ tool .remove_bitbucket_steps ( )
6455 tool .remove_configs ()
6556 tool .remove_pre_commit_repo_configs ()
6657 tool .remove_dev_deps ()
@@ -91,14 +82,14 @@ def use_deptry(*, remove: bool = False) -> None:
9182 tool .add_dev_deps ()
9283 if PreCommitTool ().is_used ():
9384 tool .add_pre_commit_repo_configs ()
94- elif is_bitbucket_used () :
95- add_bitbucket_steps_in_default ( tool .get_bitbucket_steps () )
85+ else :
86+ tool .update_bitbucket_steps ( )
9687
9788 tool .print_how_to_use ()
9889 else :
9990 tool .remove_pre_commit_repo_configs ()
10091 tool .remove_configs ()
101- remove_bitbucket_steps_from_default ( tool .get_bitbucket_steps () )
92+ tool .remove_bitbucket_steps ( )
10293 tool .remove_dev_deps ()
10394 tool .remove_managed_files ()
10495
@@ -133,14 +124,14 @@ def use_pre_commit(*, remove: bool = False) -> None:
133124
134125 install_pre_commit_hooks ()
135126
127+ tool .update_bitbucket_steps ()
136128 if is_bitbucket_used ():
137- add_bitbucket_steps_in_default (tool .get_bitbucket_steps ())
138129 _remove_bitbucket_linter_steps_from_default ()
139130
140131 tool .print_how_to_use ()
141132 else :
133+ tool .remove_bitbucket_steps ()
142134 if is_bitbucket_used ():
143- remove_bitbucket_steps_from_default (tool .get_bitbucket_steps ())
144135 _add_bitbucket_linter_steps_to_default ()
145136
146137 uninstall_pre_commit_hooks ()
@@ -177,15 +168,15 @@ def _add_bitbucket_linter_steps_to_default() -> None:
177168 tools : list [Tool ] = [PyprojectFmtTool (), DeptryTool (), RuffTool ()]
178169 for tool in tools :
179170 if tool .is_used ():
180- add_bitbucket_steps_in_default ( tool .get_bitbucket_steps () )
171+ tool .update_bitbucket_steps ( )
181172
182173
183174def _remove_bitbucket_linter_steps_from_default () -> None :
184175 # This order of removing tools should be synced with the order hard-coded
185176 # in the function which adds steps.
186- remove_bitbucket_steps_from_default ( PyprojectFmtTool ().get_bitbucket_steps () )
187- remove_bitbucket_steps_from_default ( DeptryTool ().get_bitbucket_steps () )
188- remove_bitbucket_steps_from_default ( RuffTool ().get_bitbucket_steps () )
177+ PyprojectFmtTool ().remove_bitbucket_steps ( )
178+ DeptryTool ().remove_bitbucket_steps ( )
179+ RuffTool ().remove_bitbucket_steps ( )
189180
190181
191182def use_pyproject_fmt (* , remove : bool = False ) -> None :
@@ -196,15 +187,14 @@ def use_pyproject_fmt(*, remove: bool = False) -> None:
196187 if not remove :
197188 if not PreCommitTool ().is_used ():
198189 tool .add_dev_deps ()
199- if is_bitbucket_used ():
200- add_bitbucket_steps_in_default (tool .get_bitbucket_steps ())
190+ tool .update_bitbucket_steps ()
201191 else :
202192 tool .add_pre_commit_repo_configs ()
203193
204194 tool .add_configs ()
205195 tool .print_how_to_use ()
206196 else :
207- remove_bitbucket_steps_from_default ( tool .get_bitbucket_steps () )
197+ tool .remove_bitbucket_steps ( )
208198 tool .remove_configs ()
209199 tool .remove_pre_commit_repo_configs ()
210200 tool .remove_dev_deps ()
@@ -239,16 +229,14 @@ def use_pytest(*, remove: bool = False) -> None:
239229 # https://github.com/fpgmaas/deptry/issues/302
240230 add_pytest_dir ()
241231
242- if is_bitbucket_used ():
243- update_bitbucket_pytest_steps ()
232+ PytestTool ().update_bitbucket_steps ()
244233
245234 tool .print_how_to_use ()
246235
247236 if CoverageTool ().is_used ():
248237 CoverageTool ().print_how_to_use ()
249238 else :
250- if is_bitbucket_used ():
251- remove_bitbucket_pytest_steps ()
239+ PytestTool ().remove_bitbucket_steps ()
252240
253241 if RuffTool ().is_used ():
254242 RuffTool ().deselect_rules (tool .get_associated_ruff_rules ())
@@ -342,13 +330,13 @@ def use_ruff(*, remove: bool = False) -> None:
342330 tool .ignore_rules (ignored_rules )
343331 if PreCommitTool ().is_used ():
344332 tool .add_pre_commit_repo_configs ()
345- elif is_bitbucket_used () :
346- add_bitbucket_steps_in_default ( tool .get_bitbucket_steps () )
333+ else :
334+ tool .update_bitbucket_steps ( )
347335
348336 tool .print_how_to_use ()
349337 else :
350338 tool .remove_pre_commit_repo_configs ()
351- remove_bitbucket_steps_from_default ( tool .get_bitbucket_steps () )
339+ tool .remove_bitbucket_steps ( )
352340 tool .remove_configs ()
353341 tool .remove_dev_deps ()
354342 tool .remove_managed_files ()
0 commit comments