Skip to content

Commit

Permalink
mypy: work around typing issues with functools.partial (spack#47160)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgamblin authored Oct 23, 2024
1 parent e785d37 commit f33912d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/spack/spack/filesystem_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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):
"""
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f33912d

Please sign in to comment.