From fe9a749a2dd66ff60f2ea42b9fcdacbb2fa63dfb Mon Sep 17 00:00:00 2001 From: atikulmunna Date: Sun, 16 Aug 2026 00:56:55 +0600 Subject: [PATCH] Enable mypy type checking for torchvision.io Three of the ignore_errors exemptions in mypy.ini are no longer needed: * torchvision.io.video_reader does not exist. There is no video_reader module anywhere in the tree, so the exemption matches nothing. * torchvision.io.video is a 23 line re-export shim that already carries its own type: ignore[import-not-found] for the internal fb import. * torchvision.io.image is clean apart from `import torchvision_extra_decoders`, an optional dependency imported inside a try block. That last one is handled by adding torchvision_extra_decoders to the existing ignore_missing_imports block, which is where the other optional dependencies already live (PIL, numpy, scipy, av, h5py, gdown and so on), rather than by adding an inline ignore. No source files change. mypy still reports no issues across 185 files, and the three modules are now actually checked instead of skipped. Verified with the pinned CI version, mypy 1.13.0: mypy --config-file mypy.ini Success: no issues found in 185 source files Removing the torchvision_extra_decoders entry alone reproduces the single error it suppresses, so the entry is doing real work. --- mypy.ini | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/mypy.ini b/mypy.ini index 7f722995fe9..dc18eecf091 100644 --- a/mypy.ini +++ b/mypy.ini @@ -7,18 +7,6 @@ allow_redefinition = True no_implicit_optional = True warn_redundant_casts = True -[mypy-torchvision.io.image.*] - -ignore_errors = True - -[mypy-torchvision.io.video.*] - -ignore_errors = True - -[mypy-torchvision.io.video_reader] - -ignore_errors = True - [mypy-torchvision.models.*] ignore_errors=True @@ -82,3 +70,7 @@ ignore_missing_imports = True [mypy-gdown.*] ignore_missing_imports = True + +[mypy-torchvision_extra_decoders.*] + +ignore_missing_imports = True