From 962498095d85e1baa6ff5f1690176559cdb122cd Mon Sep 17 00:00:00 2001 From: Harmen Stoppels <me@harmenstoppels.nl> Date: Sat, 18 Jan 2025 21:16:05 +0100 Subject: [PATCH] compat with mypy 1.14 (#48626) * OSError.errno apparently is int | None, but already part of __str__ anyway so drop * fix disambiguate_spec_from_hashes * List[Spec].sort() complains, ignore it * fix typing of KnownCompiler, and use it in asp.py --- lib/spack/llnl/util/filesystem.py | 3 +-- lib/spack/spack/cmd/__init__.py | 2 +- lib/spack/spack/database.py | 2 +- lib/spack/spack/solver/asp.py | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index 8e9944960d3..f280534852b 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -1740,8 +1740,7 @@ def find( def _log_file_access_issue(e: OSError, path: str) -> None: - errno_name = errno.errorcode.get(e.errno, "UNKNOWN") - tty.debug(f"find must skip {path}: {errno_name} {e}") + tty.debug(f"find must skip {path}: {e}") def _file_id(s: os.stat_result) -> Tuple[int, int]: diff --git a/lib/spack/spack/cmd/__init__.py b/lib/spack/spack/cmd/__init__.py index acb462e0580..221b6c60b76 100644 --- a/lib/spack/spack/cmd/__init__.py +++ b/lib/spack/spack/cmd/__init__.py @@ -297,7 +297,7 @@ def disambiguate_spec( def disambiguate_spec_from_hashes( spec: spack.spec.Spec, - hashes: List[str], + hashes: Optional[List[str]], local: bool = False, installed: Union[bool, InstallRecordStatus] = True, first: bool = False, diff --git a/lib/spack/spack/database.py b/lib/spack/spack/database.py index 2ebf77d9c4f..fd5db781344 100644 --- a/lib/spack/spack/database.py +++ b/lib/spack/spack/database.py @@ -1706,7 +1706,7 @@ def query( ) results = list(local_results) + list(x for x in upstream_results if x not in local_results) - results.sort() + results.sort() # type: ignore[call-overload] return results def query_one( diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index a0d2f67a127..d394c2ffc33 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -750,7 +750,7 @@ class KnownCompiler(NamedTuple): spec: spack.spec.Spec os: str - target: str + target: Optional[str] available: bool compiler_obj: Optional[spack.compiler.Compiler] @@ -1133,7 +1133,7 @@ def __init__(self, tests: bool = False): set ) - self.possible_compilers: List = [] + self.possible_compilers: List[KnownCompiler] = [] self.possible_oses: Set = set() self.variant_values_from_specs: Set = set() self.version_constraints: Set = set() -- GitLab