Fix mypy error for npz.zip.filelist optional access

This commit is contained in:
Dannon Baker
2025-12-30 23:40:34 +00:00
committed by Nicola Soranzo
parent 174240b71d
commit d4e1ba75be
+1 -1
View File
@@ -4523,7 +4523,7 @@ class Npz(CompressedArchive):
def sniff(self, filename: str) -> bool:
try:
with np.load(filename) as npz:
if isinstance(npz, np.lib.npyio.NpzFile) and any(f.filename.endswith(".npy") for f in npz.zip.filelist):
if isinstance(npz, np.lib.npyio.NpzFile) and any(f.filename.endswith(".npy") for f in npz.zip.filelist): # type: ignore[union-attr, unused-ignore]
return True
except Exception:
return False