mypy: work around typing issues with functools.partial (#47160)

This commit is contained in:
Todd Gamblin 2024-10-23 05:33:09 -07:00 committed by GitHub
parent e785d3716e
commit f33912d707
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,6 +33,7 @@
from llnl.util.tty.color import colorize
import spack.config
import spack.directory_layout
import spack.paths
import spack.projections
import spack.relocate
@ -50,7 +51,7 @@
_projections_path = ".spack/projections.yaml"
LinkCallbackType = Callable[[str, str, "FilesystemView", Optional["spack.spec.Spec"]], None]
LinkCallbackType = Callable[[str, str, "FilesystemView", Optional[spack.spec.Spec]], None]
def view_symlink(src: str, dst: str, *args, **kwargs) -> None:
@ -62,7 +63,7 @@ def view_hardlink(src: str, dst: str, *args, **kwargs) -> None:
def view_copy(
src: str, dst: str, view: "FilesystemView", spec: Optional["spack.spec.Spec"] = None
src: str, dst: str, view: "FilesystemView", spec: Optional[spack.spec.Spec] = None
) -> None:
"""
Copy a file from src to dst.
@ -160,7 +161,7 @@ class FilesystemView:
def __init__(
self,
root: str,
layout: "spack.directory_layout.DirectoryLayout",
layout: spack.directory_layout.DirectoryLayout,
*,
projections: Optional[Dict] = None,
ignore_conflicts: bool = False,
@ -182,7 +183,10 @@ def __init__(
# Setup link function to include view
self.link_type = link_type
self.link = ft.partial(function_for_link_type(link_type), view=self)
self._link = function_for_link_type(link_type)
def link(self, src: str, dst: str, spec: Optional[spack.spec.Spec] = None) -> None:
self._link(src, dst, self, spec)
def add_specs(self, *specs, **kwargs):
"""
@ -283,7 +287,7 @@ class YamlFilesystemView(FilesystemView):
def __init__(
self,
root: str,
layout: "spack.directory_layout.DirectoryLayout",
layout: spack.directory_layout.DirectoryLayout,
*,
projections: Optional[Dict] = None,
ignore_conflicts: bool = False,