1919 POETRY_SHEBANG ,
2020 PYTHON3_SHEBANG ,
2121 TEMPLATE_VERSION ,
22+ UV_MULTILINE_SHEBANG ,
23+ UV_SHEBANG ,
2224 PreCommitTemplate ,
2325)
2426from autohooks .utils import exec_git
@@ -161,6 +163,12 @@ def test_poetry_mode(self):
161163
162164 self .assertEqual (pre_commit_hook .read_mode (), Mode .POETRY )
163165
166+ def test_uv_mode (self ):
167+ path = FakeReadPath (f"#!{ UV_SHEBANG } " )
168+ pre_commit_hook = PreCommitHook (path )
169+
170+ self .assertEqual (pre_commit_hook .read_mode (), Mode .UV )
171+
164172 def test_poetry_mode_with_python3 (self ):
165173 path = FakeReadPath (f"#!{ POETRY_SHEBANG } 3" )
166174 pre_commit_hook = PreCommitHook (path )
@@ -179,6 +187,12 @@ def test_poetry_multiline_mode(self):
179187
180188 self .assertEqual (pre_commit_hook .read_mode (), Mode .POETRY_MULTILINE )
181189
190+ def test_uv_multiline_mode (self ):
191+ path = FakeReadPath (f"#!{ UV_MULTILINE_SHEBANG } " )
192+ pre_commit_hook = PreCommitHook (path )
193+
194+ self .assertEqual (pre_commit_hook .read_mode (), Mode .UV_MULTILINE )
195+
182196 def test_pythonpath_mode (self ):
183197 path = FakeReadPath (f"#!{ PYTHON3_SHEBANG } " )
184198 pre_commit_hook = PreCommitHook (path )
@@ -211,6 +225,18 @@ def test_poetry_mode(self):
211225 text = args [0 ]
212226 self .assertRegex (text , f"^#!{ POETRY_SHEBANG } *" )
213227
228+ def test_uv_mode (self ):
229+ write_path = Mock ()
230+ pre_commit_hook = PreCommitHook (write_path )
231+ pre_commit_hook .write (mode = Mode .UV )
232+
233+ write_path .chmod .assert_called_with (0o775 )
234+ self .assertTrue (write_path .write_text .called )
235+
236+ args , _kwargs = write_path .write_text .call_args
237+ text = args [0 ]
238+ self .assertRegex (text , f"^#!{ UV_SHEBANG } *" )
239+
214240 def test_pythonpath_mode (self ):
215241 write_path = Mock ()
216242 pre_commit_hook = PreCommitHook (write_path )
0 commit comments