1# This is the PyTorch mypy.ini file (note: don't change this line! - 2# test_run_mypy in test/test_type_hints.py uses this string) 3 4[mypy] 5plugins = mypy_plugins/check_mypy_version.py, mypy_plugins/sympy_mypy_plugin.py, numpy.typing.mypy_plugin 6 7cache_dir = .mypy_cache/normal 8allow_redefinition = True 9warn_unused_configs = True 10warn_redundant_casts = True 11show_error_codes = True 12show_column_numbers = True 13check_untyped_defs = True 14disallow_untyped_defs = True 15disallow_untyped_decorators = True 16follow_imports = normal 17local_partial_types = True 18enable_error_code = possibly-undefined 19 20# do not reenable this: 21# https://github.com/pytorch/pytorch/pull/60006#issuecomment-866130657 22warn_unused_ignores = False 23 24# 25# Note: test/ still has syntax errors so can't be added 26# 27# Typing tests is low priority, but enabling type checking on the 28# untyped test functions (using `--check-untyped-defs`) is still 29# high-value because it helps test the typing. 30# 31 32files = 33 torch, 34 caffe2, 35 test/test_bundled_images.py, 36 test/test_bundled_inputs.py, 37 test/test_complex.py, 38 test/test_datapipe.py, 39 test/test_futures.py, 40 test/test_numpy_interop.py, 41 test/test_torch.py, 42 test/test_type_hints.py, 43 test/test_type_info.py, 44 test/test_utils.py 45 46# 47# `exclude` is a regex, not a list of paths like `files` (sigh) 48# 49exclude = torch/include/|torch/csrc/|torch/distributed/elastic/agent/server/api.py|torch/testing/_internal|torch/distributed/fsdp/fully_sharded_data_parallel.py 50 51python_version = 3.11 52 53 54# 55# Extension modules without stubs. 56# 57 58[mypy-torch._C._jit_tree_views] 59ignore_missing_imports = True 60 61[mypy-torch.for_onnx.onnx] 62ignore_missing_imports = True 63 64[mypy-torch.ao.quantization.experimental.apot_utils] 65ignore_missing_imports = True 66 67[mypy-torch.ao.quantization.experimental.quantizer] 68ignore_missing_imports = True 69 70[mypy-torch.ao.quantization.experimental.observer] 71ignore_missing_imports = True 72 73[mypy-torch.ao.quantization.experimental.APoT_tensor] 74ignore_missing_imports = True 75 76[mypy-torch.ao.quantization.experimental.fake_quantize_function] 77ignore_missing_imports = True 78 79[mypy-torch.ao.quantization.experimental.fake_quantize] 80ignore_missing_imports = True 81 82# 83# Files with various errors. Mostly real errors, possibly some false 84# positives as well. 85# 86 87[mypy-test_torch] 88check_untyped_defs = False 89 90# Excluded from mypy due to OpInfos being annoying to type 91[mypy-torch.testing._internal.common_methods_invocations.*] 92ignore_errors = True 93 94[mypy-torch.testing._internal.hypothesis_utils.*] 95ignore_errors = True 96 97[mypy-torch.testing._internal.common_quantization.*] 98ignore_errors = True 99 100[mypy-torch.testing._internal.generated.*] 101ignore_errors = True 102 103[mypy-torch.testing._internal.distributed.*] 104ignore_errors = True 105 106[mypy-torch.nn.modules.pooling] 107ignore_errors = True 108 109[mypy-torch.nn.parallel._functions] 110ignore_errors = True 111 112[mypy-torch._appdirs] 113ignore_errors = True 114 115[mypy-torch.multiprocessing.pool] 116ignore_errors = True 117 118[mypy-torch.overrides] 119ignore_errors = True 120 121# 122# Files with 'type: ignore' comments that are needed if checked with mypy-strict.ini 123# 124 125[mypy-tools.render_junit] 126warn_unused_ignores = False 127 128[mypy-tools.generate_torch_version] 129warn_unused_ignores = False 130 131# 132# Adding type annotations to caffe2 is probably not worth the effort 133# only work on this if you have a specific reason for it, otherwise 134# leave these ignores as they are. 135# 136 137[mypy-caffe2.python.*] 138ignore_errors = True 139 140[mypy-caffe2.proto.*] 141ignore_errors = True 142 143[mypy-caffe2.distributed.store_ops_test_util] 144ignore_errors = True 145 146[mypy-caffe2.experiments.*] 147ignore_errors = True 148 149[mypy-caffe2.contrib.*] 150ignore_errors = True 151 152[mypy-caffe2.quantization.server.*] 153ignore_errors = True 154 155# 156# Third party dependencies that don't have types. 157# 158 159[mypy-triton.*] 160ignore_missing_imports = True 161 162[mypy-tensorflow.*] 163ignore_missing_imports = True 164 165[mypy-tensorboard.*] 166ignore_missing_imports = True 167 168[mypy-matplotlib.*] 169ignore_missing_imports = True 170 171[mypy-numpy.*] 172ignore_missing_imports = True 173 174[mypy-sympy] 175ignore_missing_imports = True 176 177[mypy-sympy.*] 178ignore_missing_imports = True 179 180[mypy-hypothesis.*] 181ignore_missing_imports = True 182 183[mypy-tqdm.*] 184ignore_missing_imports = True 185 186[mypy-multiprocessing.*] 187ignore_missing_imports = True 188 189[mypy-setuptools.*] 190ignore_missing_imports = True 191 192[mypy-distutils.*] 193ignore_missing_imports = True 194 195[mypy-nvd3.*] 196ignore_missing_imports = True 197 198[mypy-future.utils] 199ignore_missing_imports = True 200 201[mypy-past.builtins] 202ignore_missing_imports = True 203 204[mypy-numba.*] 205ignore_missing_imports = True 206 207[mypy-PIL.*] 208ignore_missing_imports = True 209 210[mypy-moviepy.*] 211ignore_missing_imports = True 212 213[mypy-cv2.*] 214ignore_missing_imports = True 215 216[mypy-torchvision.*] 217ignore_missing_imports = True 218 219[mypy-pycuda.*] 220ignore_missing_imports = True 221 222[mypy-tensorrt.*] 223ignore_missing_imports = True 224 225[mypy-tornado.*] 226ignore_missing_imports = True 227 228[mypy-pydot.*] 229ignore_missing_imports = True 230 231[mypy-networkx.*] 232ignore_missing_imports = True 233 234[mypy-scipy.*] 235ignore_missing_imports = True 236 237[mypy-IPython.*] 238ignore_missing_imports = True 239 240[mypy-google.protobuf.textformat] 241ignore_missing_imports = True 242 243[mypy-lmdb.*] 244ignore_missing_imports = True 245 246[mypy-mpi4py.*] 247ignore_missing_imports = True 248 249[mypy-skimage.*] 250ignore_missing_imports = True 251 252[mypy-librosa.*] 253ignore_missing_imports = True 254 255[mypy-mypy.*] 256ignore_missing_imports = True 257 258[mypy-xml.*] 259ignore_missing_imports = True 260 261[mypy-boto3.*] 262ignore_missing_imports = True 263 264[mypy-dill.*] 265ignore_missing_imports = True 266 267[mypy-usort.*] 268ignore_missing_imports = True 269 270[mypy-torch._inductor.*] 271disallow_any_generics = True 272 273[mypy-torch._dynamo.*] 274disallow_any_generics = True 275 276[mypy-cutlass_library.*] 277ignore_missing_imports = True 278 279[mypy-deeplearning.*] 280ignore_missing_imports = True 281 282[mypy-einops.*] 283ignore_missing_imports = True 284 285[mypy-libfb.*] 286ignore_missing_imports = True 287 288[mypy-torch.*.fb.*] 289ignore_missing_imports = True 290 291[mypy-torch.fb.*] 292ignore_missing_imports = True 293 294[mypy-torch_xla.*] 295ignore_missing_imports = True 296 297# 298# Third party dependencies that are optional. 299# 300 301[mypy-onnx.*] 302ignore_missing_imports = True 303 304[mypy-onnxruntime.*] 305ignore_missing_imports = True 306 307[mypy-onnxscript.*] 308ignore_missing_imports = True 309 310[mypy-redis] 311ignore_missing_imports = True