add quotes to type annotation

Signed-off-by: Todd Gamblin <tgamblin@llnl.gov>
This commit is contained in:
Todd Gamblin 2025-02-10 22:04:34 -08:00 committed by Gregory Becker
parent 4a153a185b
commit 8d0923f29e
No known key found for this signature in database
GPG Key ID: 2362541F6D14ED84

View File

@ -75,6 +75,7 @@
_fail_fast_err = "Terminating after first install failure" _fail_fast_err = "Terminating after first install failure"
class BuildStatus(enum.Enum): class BuildStatus(enum.Enum):
"""Different build (task) states.""" """Different build (task) states."""
@ -123,6 +124,7 @@ class ExecuteResult(enum.Enum):
# task is not ready for installation (locked by another process) # task is not ready for installation (locked by another process)
NO_OP = enum.auto() NO_OP = enum.auto()
class InstallAction(enum.Enum): class InstallAction(enum.Enum):
#: Don't perform an install #: Don't perform an install
NONE = enum.auto() NONE = enum.auto()
@ -1067,7 +1069,6 @@ def flag_installed(self, installed: List[str]) -> None:
level=2, level=2,
) )
def _setup_install_dir(self, pkg: "spack.package_base.PackageBase") -> None: def _setup_install_dir(self, pkg: "spack.package_base.PackageBase") -> None:
""" """
Create and ensure proper access controls for the install directory. Create and ensure proper access controls for the install directory.
@ -1182,9 +1183,8 @@ def priority(self):
"""The priority is based on the remaining uninstalled dependencies.""" """The priority is based on the remaining uninstalled dependencies."""
return len(self.uninstalled_deps) return len(self.uninstalled_deps)
def check_db(
spec: "spack.spec.Spec" def check_db(spec: "spack.spec.Spec") -> Tuple[Optional[spack.database.InstallRecord], bool]:
) -> Tuple[Optional[spack.database.InstallRecord], bool]:
"""Determine if the spec is flagged as installed in the database """Determine if the spec is flagged as installed in the database
Args: Args:
@ -1204,10 +1204,11 @@ def check_db(
installed_in_db = False installed_in_db = False
return rec, installed_in_db return rec, installed_in_db
class BuildTask(Task): class BuildTask(Task):
"""Class for representing a build task for a package.""" """Class for representing a build task for a package."""
process_handle: spack.build_environment.ProcessHandle = None process_handle: "spack.build_environment.ProcessHandle" = None
started: bool = False started: bool = False
no_op: bool = False no_op: bool = False
@ -1262,7 +1263,9 @@ def start(self):
def poll(self): def poll(self):
"""Check if task has successfully executed, caused an InstallError, """Check if task has successfully executed, caused an InstallError,
or the child process has information ready to receive.""" or the child process has information ready to receive."""
assert self.started or self.no_op, "Can't call `poll()` before `start()` or identified no-operation task" assert (
self.started or self.no_op
), "Can't call `poll()` before `start()` or identified no-operation task"
return self.no_op or self.success_result or self.error_result or self.process_handle.poll() return self.no_op or self.success_result or self.error_result or self.process_handle.poll()
def complete(self): def complete(self):
@ -1270,7 +1273,9 @@ def complete(self):
Complete the installation of the requested spec and/or dependency Complete the installation of the requested spec and/or dependency
represented by the build task. represented by the build task.
""" """
assert self.started or self.no_op, "Can't call `complete()` before `start()` or identified no-operation task" assert (
self.started or self.no_op
), "Can't call `complete()` before `start()` or identified no-operation task"
# seeing if I can get rid of that assertion because in some cases we will need to # seeing if I can get rid of that assertion because in some cases we will need to
# complete the task so that we can raise the errors even though a process was never # complete the task so that we can raise the errors even though a process was never
# started because saving the error made it exit the function before a process could be started # started because saving the error made it exit the function before a process could be started
@ -1518,7 +1523,6 @@ def _add_init_task(
self._push_task(task) self._push_task(task)
def _check_deps_status(self, request: BuildRequest) -> None: def _check_deps_status(self, request: BuildRequest) -> None:
"""Check the install status of the requested package """Check the install status of the requested package
@ -2116,8 +2120,9 @@ def _init_queue(self) -> None:
task.add_dependent(dependent_id) task.add_dependent(dependent_id)
self.all_dependencies = all_dependencies self.all_dependencies = all_dependencies
def start_task(
def start_task(self, task: Task, install_status: InstallStatus, term_status: TermStatusLine) -> None: self, task: Task, install_status: InstallStatus, term_status: TermStatusLine
) -> None:
"""Attempts to start a package installation.""" """Attempts to start a package installation."""
pkg, pkg_id, spec = task.pkg, task.pkg_id, task.pkg.spec pkg, pkg_id, spec = task.pkg, task.pkg_id, task.pkg.spec
install_status.next_pkg(pkg) install_status.next_pkg(pkg)
@ -2281,14 +2286,11 @@ def complete_task(self, task: Task, install_status: InstallStatus) -> Optional[T
# lower levels -- skip printing if already printed. # lower levels -- skip printing if already printed.
# TODO: sort out this and SpackError.print_context() # TODO: sort out this and SpackError.print_context()
tty.error( tty.error(
f"Failed to install {pkg.name} due to " f"Failed to install {pkg.name} due to " f"{exc.__class__.__name__}: {str(exc)}"
f"{exc.__class__.__name__}: {str(exc)}"
) )
# Terminate if requested to do so on the first failure. # Terminate if requested to do so on the first failure.
if self.fail_fast: if self.fail_fast:
raise spack.error.InstallError( raise spack.error.InstallError(f"{_fail_fast_err}: {str(exc)}", pkg=pkg) from exc
f"{_fail_fast_err}: {str(exc)}", pkg=pkg
) from exc
# Terminate when a single build request has failed, or summarize errors later. # Terminate when a single build request has failed, or summarize errors later.
if task.is_build_request: if task.is_build_request:
@ -2357,7 +2359,6 @@ def install(self) -> None:
finally: finally:
active_tasks.remove(task) active_tasks.remove(task)
self._clear_removed_tasks() self._clear_removed_tasks()
if self.build_pq: if self.build_pq:
task = self._pop_task() task = self._pop_task()
@ -2640,6 +2641,7 @@ def build_process(pkg: "spack.package_base.PackageBase", install_args: dict) ->
with spack.util.path.filter_padding(): with spack.util.path.filter_padding():
return installer.run() return installer.run()
def overwrite_process(pkg: "spack.package_base.PackageBase", install_args: dict) -> bool: def overwrite_process(pkg: "spack.package_base.PackageBase", install_args: dict) -> bool:
# TODO:I don't know if this comment accurately reflects what's going on anymore # TODO:I don't know if this comment accurately reflects what's going on anymore
# TODO: think it should move to the error handling # TODO: think it should move to the error handling
@ -2650,6 +2652,7 @@ def overwrite_process(pkg: "spack.package_base.PackageBase", install_args: dict)
with fs.replace_directory_transaction(pkg.prefix): with fs.replace_directory_transaction(pkg.prefix):
return build_process(pkg, install_args) return build_process(pkg, install_args)
def deprecate(spec: "spack.spec.Spec", deprecator: "spack.spec.Spec", link_fn) -> None: def deprecate(spec: "spack.spec.Spec", deprecator: "spack.spec.Spec", link_fn) -> None:
"""Deprecate this package in favor of deprecator spec""" """Deprecate this package in favor of deprecator spec"""
# Here we assume we don't deprecate across different stores, and that same hash # Here we assume we don't deprecate across different stores, and that same hash