3
3
from pathlib import Path
4
4
from typing import TYPE_CHECKING
5
5
6
- from usethis ._ci import (
7
- is_bitbucket_used ,
8
- remove_bitbucket_pytest_steps ,
9
- update_bitbucket_pytest_steps ,
10
- )
11
6
from usethis ._config import usethis_config
12
7
from 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
17
9
from usethis ._integrations .file .pyproject_toml .valid import ensure_pyproject_validity
18
10
from usethis ._integrations .pre_commit .core import (
19
11
install_pre_commit_hooks ,
@@ -52,15 +44,14 @@ def use_codespell(*, remove: bool = False) -> None:
52
44
if not remove :
53
45
if not PreCommitTool ().is_used ():
54
46
tool .add_dev_deps ()
55
- if is_bitbucket_used ():
56
- add_bitbucket_steps_in_default (tool .get_bitbucket_steps ())
47
+ tool .update_bitbucket_steps ()
57
48
else :
58
49
tool .add_pre_commit_repo_configs ()
59
50
60
51
tool .add_configs ()
61
52
tool .print_how_to_use ()
62
53
else :
63
- remove_bitbucket_steps_from_default ( tool .get_bitbucket_steps () )
54
+ tool .remove_bitbucket_steps ( )
64
55
tool .remove_configs ()
65
56
tool .remove_pre_commit_repo_configs ()
66
57
tool .remove_dev_deps ()
@@ -91,14 +82,14 @@ def use_deptry(*, remove: bool = False) -> None:
91
82
tool .add_dev_deps ()
92
83
if PreCommitTool ().is_used ():
93
84
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 ( )
96
87
97
88
tool .print_how_to_use ()
98
89
else :
99
90
tool .remove_pre_commit_repo_configs ()
100
91
tool .remove_configs ()
101
- remove_bitbucket_steps_from_default ( tool .get_bitbucket_steps () )
92
+ tool .remove_bitbucket_steps ( )
102
93
tool .remove_dev_deps ()
103
94
tool .remove_managed_files ()
104
95
@@ -133,14 +124,14 @@ def use_pre_commit(*, remove: bool = False) -> None:
133
124
134
125
install_pre_commit_hooks ()
135
126
127
+ tool .update_bitbucket_steps ()
136
128
if is_bitbucket_used ():
137
- add_bitbucket_steps_in_default (tool .get_bitbucket_steps ())
138
129
_remove_bitbucket_linter_steps_from_default ()
139
130
140
131
tool .print_how_to_use ()
141
132
else :
133
+ tool .remove_bitbucket_steps ()
142
134
if is_bitbucket_used ():
143
- remove_bitbucket_steps_from_default (tool .get_bitbucket_steps ())
144
135
_add_bitbucket_linter_steps_to_default ()
145
136
146
137
uninstall_pre_commit_hooks ()
@@ -177,15 +168,15 @@ def _add_bitbucket_linter_steps_to_default() -> None:
177
168
tools : list [Tool ] = [PyprojectFmtTool (), DeptryTool (), RuffTool ()]
178
169
for tool in tools :
179
170
if tool .is_used ():
180
- add_bitbucket_steps_in_default ( tool .get_bitbucket_steps () )
171
+ tool .update_bitbucket_steps ( )
181
172
182
173
183
174
def _remove_bitbucket_linter_steps_from_default () -> None :
184
175
# This order of removing tools should be synced with the order hard-coded
185
176
# 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 ( )
189
180
190
181
191
182
def use_pyproject_fmt (* , remove : bool = False ) -> None :
@@ -196,15 +187,14 @@ def use_pyproject_fmt(*, remove: bool = False) -> None:
196
187
if not remove :
197
188
if not PreCommitTool ().is_used ():
198
189
tool .add_dev_deps ()
199
- if is_bitbucket_used ():
200
- add_bitbucket_steps_in_default (tool .get_bitbucket_steps ())
190
+ tool .update_bitbucket_steps ()
201
191
else :
202
192
tool .add_pre_commit_repo_configs ()
203
193
204
194
tool .add_configs ()
205
195
tool .print_how_to_use ()
206
196
else :
207
- remove_bitbucket_steps_from_default ( tool .get_bitbucket_steps () )
197
+ tool .remove_bitbucket_steps ( )
208
198
tool .remove_configs ()
209
199
tool .remove_pre_commit_repo_configs ()
210
200
tool .remove_dev_deps ()
@@ -239,16 +229,14 @@ def use_pytest(*, remove: bool = False) -> None:
239
229
# https://github.com/fpgmaas/deptry/issues/302
240
230
add_pytest_dir ()
241
231
242
- if is_bitbucket_used ():
243
- update_bitbucket_pytest_steps ()
232
+ PytestTool ().update_bitbucket_steps ()
244
233
245
234
tool .print_how_to_use ()
246
235
247
236
if CoverageTool ().is_used ():
248
237
CoverageTool ().print_how_to_use ()
249
238
else :
250
- if is_bitbucket_used ():
251
- remove_bitbucket_pytest_steps ()
239
+ PytestTool ().remove_bitbucket_steps ()
252
240
253
241
if RuffTool ().is_used ():
254
242
RuffTool ().deselect_rules (tool .get_associated_ruff_rules ())
@@ -342,13 +330,13 @@ def use_ruff(*, remove: bool = False) -> None:
342
330
tool .ignore_rules (ignored_rules )
343
331
if PreCommitTool ().is_used ():
344
332
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 ( )
347
335
348
336
tool .print_how_to_use ()
349
337
else :
350
338
tool .remove_pre_commit_repo_configs ()
351
- remove_bitbucket_steps_from_default ( tool .get_bitbucket_steps () )
339
+ tool .remove_bitbucket_steps ( )
352
340
tool .remove_configs ()
353
341
tool .remove_dev_deps ()
354
342
tool .remove_managed_files ()
0 commit comments