1111import os
1212from functools import partial
1313from optparse import Values
14- from typing import Any
14+ from typing import Any , Callable , TypeVar
1515
1616from pip ._internal .build_env import SubprocessBuildEnvironmentInstaller
1717from pip ._internal .cache import WheelCache
@@ -62,7 +62,12 @@ def should_ignore_regular_constraints(options: Values) -> bool:
6262]
6363
6464
65- def with_cleanup (func : Any ) -> Any :
65+ _CommandT = TypeVar ("_CommandT" , bound = "RequirementCommand" )
66+
67+
68+ def with_cleanup (
69+ func : Callable [[_CommandT , Values , list [str ]], int ],
70+ ) -> Callable [[_CommandT , Values , list [str ]], int ]:
6671 """Decorator for common logic related to managing temporary
6772 directories.
6873 """
@@ -71,9 +76,7 @@ def configure_tempdir_registry(registry: TempDirectoryTypeRegistry) -> None:
7176 for t in KEEPABLE_TEMPDIR_TYPES :
7277 registry .set_delete (t , False )
7378
74- def wrapper (
75- self : RequirementCommand , options : Values , args : list [Any ]
76- ) -> int | None :
79+ def wrapper (self : _CommandT , options : Values , args : list [str ]) -> int :
7780 assert self .tempdir_registry is not None
7881 if options .no_clean :
7982 configure_tempdir_registry (self .tempdir_registry )
0 commit comments