@@ -201,6 +201,8 @@ def using_database_replica(
201201 # Already has the desired behavior; re-export for uniform imports.
202202 TemporaryDirectory = tempfile .TemporaryDirectory
203203else :
204+ from os import PathLike
205+ from types import TracebackType
204206
205207 class TemporaryDirectory (tempfile .TemporaryDirectory ):
206208 """
@@ -217,20 +219,34 @@ class TemporaryDirectory(tempfile.TemporaryDirectory):
217219
218220 def __init__ (
219221 self ,
220- * args : object ,
222+ suffix : str | None = None ,
223+ prefix : str | None = None ,
224+ dir : str | PathLike [str ] | None = None ,
225+ ignore_cleanup_errors : bool = False ,
226+ * ,
221227 delete : bool = True ,
222- ):
228+ ) -> None :
223229 self .delete = delete
224- super ().__init__ (* args )
225-
226- def __exit__ (self , exc_type , exc , tb ):
230+ super ().__init__ (
231+ suffix = suffix ,
232+ prefix = prefix ,
233+ dir = dir ,
234+ ignore_cleanup_errors = ignore_cleanup_errors ,
235+ )
236+
237+ def __exit__ (
238+ self ,
239+ exc_type : type [BaseException ] | None ,
240+ exc : BaseException | None ,
241+ tb : TracebackType | None ,
242+ ) -> bool :
227243 """On context exit, only cleanup if delete=True."""
228244 if self .delete :
229245 super ().__exit__ (exc_type , exc , tb )
230246 # Return False to propagate exceptions like the stdlib does.
231247 return False
232248
233- def _cleanup (self , name , warn_message ) :
249+ def _cleanup (self , name : str , warn_message : str ) -> None :
234250 """
235251 Called by the weakref finalizer on GC in 3.11.
236252 Respect delete=False by doing nothing in that case.
0 commit comments