66 update_bitbucket_pytest_steps ,
77)
88from usethis ._config import usethis_config
9- from usethis ._console import box_print , tick_print
9+ from usethis ._console import tick_print
1010from usethis ._integrations .bitbucket .steps import (
1111 add_bitbucket_steps_in_default ,
1212 remove_bitbucket_steps_from_default ,
@@ -50,38 +50,22 @@ def use_codespell(*, remove: bool = False) -> None:
5050 ensure_pyproject_toml ()
5151
5252 if not remove :
53- is_pre_commit = PreCommitTool ().is_used ()
54-
55- if not is_pre_commit :
53+ if not PreCommitTool ().is_used ():
5654 add_deps_to_group (tool .dev_deps , "dev" )
5755 if is_bitbucket_used ():
5856 add_bitbucket_steps_in_default (tool .get_bitbucket_steps ())
5957 else :
6058 tool .add_pre_commit_repo_configs ()
6159
6260 tool .add_pyproject_configs ()
63-
64- if not is_pre_commit :
65- _codespell_instructions_basic ()
66- else :
67- _codespell_instructions_pre_commit ()
61+ tool .print_how_to_use ()
6862 else :
6963 remove_bitbucket_steps_from_default (tool .get_bitbucket_steps ())
7064 tool .remove_pyproject_configs ()
7165 tool .remove_pre_commit_repo_configs ()
7266 remove_deps_from_group (tool .dev_deps , "dev" )
7367
7468
75- def _codespell_instructions_basic () -> None :
76- box_print ("Run 'codespell' to run the Codespell spellchecker." )
77-
78-
79- def _codespell_instructions_pre_commit () -> None :
80- box_print (
81- "Run 'pre-commit run codespell --all-files' to run the Codespell spellchecker."
82- )
83-
84-
8569def use_coverage (* , remove : bool = False ) -> None :
8670 tool = CoverageTool ()
8771
@@ -94,24 +78,12 @@ def use_coverage(*, remove: bool = False) -> None:
9478 add_deps_to_group (deps , "test" )
9579
9680 tool .add_pyproject_configs ()
97-
98- if PytestTool ().is_used ():
99- _coverage_instructions_pytest ()
100- else :
101- _coverage_instructions_basic ()
81+ tool .print_how_to_use ()
10282 else :
10383 tool .remove_pyproject_configs ()
10484 remove_deps_from_group ([* tool .dev_deps , Dependency (name = "pytest-cov" )], "test" )
10585
10686
107- def _coverage_instructions_basic () -> None :
108- box_print ("Run 'coverage help' to see available coverage commands." )
109-
110-
111- def _coverage_instructions_pytest () -> None :
112- box_print ("Run 'pytest --cov' to run your tests with coverage." )
113-
114-
11587def use_deptry (* , remove : bool = False ) -> None :
11688 tool = DeptryTool ()
11789
@@ -124,7 +96,7 @@ def use_deptry(*, remove: bool = False) -> None:
12496 elif is_bitbucket_used ():
12597 add_bitbucket_steps_in_default (tool .get_bitbucket_steps ())
12698
127- box_print ( "Run 'deptry src' to run deptry." )
99+ tool . print_how_to_use ( )
128100 else :
129101 tool .remove_pre_commit_repo_configs ()
130102 tool .remove_pyproject_configs ()
@@ -147,14 +119,14 @@ def use_pre_commit(*, remove: bool = False) -> None:
147119 if pyproject_fmt_tool .is_used ():
148120 remove_deps_from_group (pyproject_fmt_tool .dev_deps , "dev" )
149121 pyproject_fmt_tool .add_pyproject_configs ()
150- _pyproject_fmt_instructions_pre_commit ()
122+ PyprojectFmtTool (). print_how_to_use ()
151123 if codespell_tool .is_used ():
152124 remove_deps_from_group (codespell_tool .dev_deps , "dev" )
153125 codespell_tool .add_pyproject_configs ()
154- _codespell_instructions_pre_commit ()
126+ CodespellTool (). print_how_to_use ()
155127
156128 if RequirementsTxtTool ().is_used ():
157- _requirements_txt_instructions_pre_commit ()
129+ RequirementsTxtTool (). print_how_to_use ()
158130
159131 if not get_hook_names ():
160132 add_placeholder_hook ()
@@ -165,7 +137,7 @@ def use_pre_commit(*, remove: bool = False) -> None:
165137 add_bitbucket_steps_in_default (tool .get_bitbucket_steps ())
166138 _remove_bitbucket_linter_steps_from_default ()
167139
168- box_print ( "Run 'pre-commit run --all-files' to run the hooks manually." )
140+ tool . print_how_to_use ( )
169141 else :
170142 if is_bitbucket_used ():
171143 remove_bitbucket_steps_from_default (tool .get_bitbucket_steps ())
@@ -180,15 +152,15 @@ def use_pre_commit(*, remove: bool = False) -> None:
180152 # dependencies yet - explain to the user.
181153 if pyproject_fmt_tool .is_used ():
182154 add_deps_to_group (pyproject_fmt_tool .dev_deps , "dev" )
183- _pyproject_fmt_instructions_basic ()
155+ PyprojectFmtTool (). print_how_to_use ()
184156 if codespell_tool .is_used ():
185157 add_deps_to_group (codespell_tool .dev_deps , "dev" )
186- _codespell_instructions_basic ()
158+ CodespellTool (). print_how_to_use ()
187159
188160 # Likewise, explain how to manually generate the requirements.txt file, since
189161 # they're not going to do it via pre-commit anymore.
190162 if RequirementsTxtTool ().is_used ():
191- _requirements_txt_instructions_basic ()
163+ RequirementsTxtTool (). print_how_to_use ()
192164
193165
194166def _add_all_tools_pre_commit_configs ():
@@ -221,36 +193,22 @@ def use_pyproject_fmt(*, remove: bool = False) -> None:
221193 ensure_pyproject_toml ()
222194
223195 if not remove :
224- is_pre_commit = PreCommitTool ().is_used ()
225-
226- if not is_pre_commit :
196+ if not PreCommitTool ().is_used ():
227197 add_deps_to_group (tool .dev_deps , "dev" )
228198 if is_bitbucket_used ():
229199 add_bitbucket_steps_in_default (tool .get_bitbucket_steps ())
230200 else :
231201 tool .add_pre_commit_repo_configs ()
232202
233203 tool .add_pyproject_configs ()
234-
235- if not is_pre_commit :
236- _pyproject_fmt_instructions_basic ()
237- else :
238- _pyproject_fmt_instructions_pre_commit ()
204+ tool .print_how_to_use ()
239205 else :
240206 remove_bitbucket_steps_from_default (tool .get_bitbucket_steps ())
241207 tool .remove_pyproject_configs ()
242208 tool .remove_pre_commit_repo_configs ()
243209 remove_deps_from_group (tool .dev_deps , "dev" )
244210
245211
246- def _pyproject_fmt_instructions_basic () -> None :
247- box_print ("Run 'pyproject-fmt pyproject.toml' to run pyproject-fmt." )
248-
249-
250- def _pyproject_fmt_instructions_pre_commit () -> None :
251- box_print ("Run 'pre-commit run pyproject-fmt --all-files' to run pyproject-fmt." )
252-
253-
254212def use_pytest (* , remove : bool = False ) -> None :
255213 tool = PytestTool ()
256214
@@ -273,14 +231,10 @@ def use_pytest(*, remove: bool = False) -> None:
273231 if is_bitbucket_used ():
274232 update_bitbucket_pytest_steps ()
275233
276- box_print (
277- "Add test files to the '/tests' directory with the format 'test_*.py'."
278- )
279- box_print ("Add test functions with the format 'test_*()'." )
280- box_print ("Run 'pytest' to run the tests." )
234+ tool .print_how_to_use ()
281235
282236 if CoverageTool ().is_used ():
283- _coverage_instructions_pytest ()
237+ CoverageTool (). print_how_to_use ()
284238 else :
285239 if is_bitbucket_used ():
286240 remove_bitbucket_pytest_steps ()
@@ -293,7 +247,7 @@ def use_pytest(*, remove: bool = False) -> None:
293247 remove_pytest_dir () # Last, since this is a manual step
294248
295249 if CoverageTool ().is_used ():
296- _coverage_instructions_basic ()
250+ CoverageTool (). print_how_to_use ()
297251
298252
299253def use_requirements_txt (* , remove : bool = False ) -> None :
@@ -327,10 +281,8 @@ def use_requirements_txt(*, remove: bool = False) -> None:
327281 change_toml = False ,
328282 )
329283
330- if not is_pre_commit :
331- _requirements_txt_instructions_basic ()
332- else :
333- _requirements_txt_instructions_pre_commit ()
284+ tool .print_how_to_use ()
285+
334286 else :
335287 tool .remove_pre_commit_repo_configs ()
336288
@@ -339,16 +291,6 @@ def use_requirements_txt(*, remove: bool = False) -> None:
339291 path .unlink ()
340292
341293
342- def _requirements_txt_instructions_basic () -> None :
343- box_print (
344- "Run 'uv export --no-dev --output-file=requirements.txt' to write 'requirements.txt'."
345- )
346-
347-
348- def _requirements_txt_instructions_pre_commit () -> None :
349- box_print ("Run the 'pre-commit run uv-export' to write 'requirements.txt'." )
350-
351-
352294def use_ruff (* , remove : bool = False ) -> None :
353295 tool = RuffTool ()
354296
@@ -388,8 +330,7 @@ def use_ruff(*, remove: bool = False) -> None:
388330 elif is_bitbucket_used ():
389331 add_bitbucket_steps_in_default (tool .get_bitbucket_steps ())
390332
391- box_print ("Run 'ruff check --fix' to run the Ruff linter with autofixes." )
392- box_print ("Run 'ruff format' to run the Ruff formatter." )
333+ tool .print_how_to_use ()
393334 else :
394335 tool .remove_pre_commit_repo_configs ()
395336 remove_bitbucket_steps_from_default (tool .get_bitbucket_steps ())
0 commit comments