Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/pip/_internal/cli/req_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import logging
from functools import partial
from optparse import Values
from typing import Any
from typing import Any, Callable, TypeVar

from pip._internal.build_env import SubprocessBuildEnvironmentInstaller
from pip._internal.cache import WheelCache
Expand Down Expand Up @@ -51,7 +51,12 @@
]


def with_cleanup(func: Any) -> Any:
_CommandT = TypeVar("_CommandT", bound="RequirementCommand")


def with_cleanup(
func: Callable[[_CommandT, Values, list[str]], int],
) -> Callable[[_CommandT, Values, list[str]], int]:
"""Decorator for common logic related to managing temporary
directories.
"""
Expand All @@ -60,9 +65,7 @@ def configure_tempdir_registry(registry: TempDirectoryTypeRegistry) -> None:
for t in KEEPABLE_TEMPDIR_TYPES:
registry.set_delete(t, False)

def wrapper(
self: RequirementCommand, options: Values, args: list[Any]
) -> int | None:
def wrapper(self: _CommandT, options: Values, args: list[str]) -> int:
assert self.tempdir_registry is not None
if options.no_clean:
configure_tempdir_registry(self.tempdir_registry)
Expand Down