diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py
index 8e9944960d3a06bcf8e63084a62a3b72aad40168..f280534852bbec77496e20fc09bc558f63b35ad2 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 acb462e058022a1e70f3cf3b6c2f265c3dd872ed..221b6c60b768b13f959926380c34cb8e3990c975 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 2ebf77d9c4fccaedb67f91af5cef43e3da18a4bf..fd5db781344af43900531948c345de45c89607dd 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 a0d2f67a1270ef2447461009a5862aaab604ea95..d394c2ffc33977df5c73008edbf9152209e01496 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()