77 remove_bitbucket_pytest_steps ,
88 update_bitbucket_pytest_steps ,
99)
10- from usethis ._console import box_print , info_print , tick_print
10+ from usethis ._console import box_print , tick_print
1111from usethis ._integrations .pre_commit .core import (
1212 install_pre_commit_hooks ,
1313 remove_pre_commit_config ,
@@ -44,7 +44,7 @@ def use_deptry(*, remove: bool = False) -> None:
4444 if PreCommitTool ().is_used ():
4545 tool .add_pre_commit_repo_configs ()
4646
47- box_print ("Call the 'deptry src' command to run deptry." )
47+ box_print ("Run 'deptry src' to run deptry." )
4848 else :
4949 if PreCommitTool ().is_used ():
5050 tool .remove_pre_commit_repo_configs ()
@@ -78,9 +78,7 @@ def use_pre_commit(*, remove: bool = False) -> None:
7878 if is_bitbucket_used ():
7979 add_bitbucket_pre_commit_step ()
8080
81- box_print (
82- "Call the 'pre-commit run --all-files' command to run the hooks manually."
83- )
81+ box_print ("Run 'pre-commit run --all-files' to run the hooks manually." )
8482 else :
8583 if is_bitbucket_used ():
8684 remove_bitbucket_pre_commit_step ()
@@ -117,12 +115,10 @@ def use_pyproject_fmt(*, remove: bool = False) -> None:
117115 tool .add_pyproject_configs ()
118116
119117 if not is_pre_commit :
120- box_print (
121- "Call the 'pyproject-fmt pyproject.toml' command to run pyproject-fmt."
122- )
118+ box_print ("Run 'pyproject-fmt pyproject.toml' to run pyproject-fmt." )
123119 else :
124120 box_print (
125- "Call the 'pre-commit run pyproject-fmt --all-files' command to run pyproject-fmt."
121+ "Run 'pre-commit run pyproject-fmt --all-files' to run pyproject-fmt."
126122 )
127123 else :
128124 tool .remove_pyproject_configs ()
@@ -152,7 +148,7 @@ def use_pytest(*, remove: bool = False) -> None:
152148 "Add test files to the '/tests' directory with the format 'test_*.py'."
153149 )
154150 box_print ("Add test functions with the format 'test_*()'." )
155- box_print ("Call the 'pytest' command to run the tests." )
151+ box_print ("Run 'pytest' to run the tests." )
156152 else :
157153 if is_bitbucket_used ():
158154 remove_bitbucket_pytest_steps ()
@@ -167,6 +163,8 @@ def use_pytest(*, remove: bool = False) -> None:
167163def use_requirements_txt (* , remove : bool = False ) -> None :
168164 tool = RequirementsTxtTool ()
169165
166+ ensure_pyproject_toml ()
167+
170168 path = Path .cwd () / "requirements.txt"
171169
172170 if not remove :
@@ -177,28 +175,26 @@ def use_requirements_txt(*, remove: bool = False) -> None:
177175
178176 if not path .exists ():
179177 # N.B. this is where a task runner would come in handy, to reduce duplication.
178+ if not (Path .cwd () / "uv.lock" ).exists ():
179+ tick_print ("Writing 'uv.lock'." )
180+ call_uv_subprocess (["lock" ])
181+
180182 tick_print ("Writing 'requirements.txt'." )
181183 call_uv_subprocess (
182184 [
183185 "export" ,
184186 "--frozen" ,
185187 "--no-dev" ,
186188 "--output-file=requirements.txt" ,
187- "--quiet" ,
188189 ]
189190 )
190191
191192 if not is_pre_commit :
192193 box_print (
193- "Call the 'uv export --frozen --no-dev --output-file=requirements.txt --quiet' command to manually export to 'requirements.txt'."
194- )
195- info_print (
196- "You can automate the export of requirements.txt with pre-commit. Try `usethis tool pre-commit`."
194+ "Run 'uv export --no-dev --output-file=requirements.txt' to write 'requirements.txt'."
197195 )
198196 else :
199- box_print (
200- "Call the 'pre-commit run uv-export' command to manually export to 'requirements.txt'."
201- )
197+ box_print ("Run the 'pre-commit run uv-export' to write 'requirements.txt'." )
202198 else :
203199 if PreCommitTool ().is_used ():
204200 tool .remove_pre_commit_repo_configs ()
@@ -245,10 +241,8 @@ def use_ruff(*, remove: bool = False) -> None:
245241 if PreCommitTool ().is_used ():
246242 tool .add_pre_commit_repo_configs ()
247243
248- box_print (
249- "Call the 'ruff check --fix' command to run the Ruff linter with autofixes."
250- )
251- box_print ("Call the 'ruff format' command to run the Ruff formatter." )
244+ box_print ("Run 'ruff check --fix' to run the Ruff linter with autofixes." )
245+ box_print ("Run 'ruff format' to run the Ruff formatter." )
252246 else :
253247 if PreCommitTool ().is_used ():
254248 tool .remove_pre_commit_repo_configs ()
0 commit comments