From 27f9d3b0a17289500f1a2d24e4901a1e0fa9ea95 Mon Sep 17 00:00:00 2001 From: Aaron Orenstein Date: Sat, 8 Jun 2024 11:41:15 -0700 Subject: [PATCH] Flip default value for mypy disallow_untyped_defs [8/11] (#127845) See #127836 for details. Pull Request resolved: https://github.com/pytorch/pytorch/pull/127845 Approved by: https://github.com/oulgen ghstack dependencies: #127842, #127843, #127844 --- torch/nn/backends/thnn.py | 1 + torch/nn/cpp.py | 1 + torch/nn/grad.py | 1 + torch/nn/init.py | 1 + torch/nn/modules/_functions.py | 1 + torch/nn/modules/activation.py | 1 + torch/nn/modules/adaptive.py | 1 + torch/nn/modules/batchnorm.py | 1 + torch/nn/modules/container.py | 1 + torch/nn/modules/conv.py | 1 + torch/nn/modules/flatten.py | 1 + torch/nn/modules/instancenorm.py | 1 + torch/nn/modules/lazy.py | 1 + torch/nn/modules/linear.py | 1 + torch/nn/modules/loss.py | 1 + torch/nn/modules/module.py | 1 + torch/nn/modules/normalization.py | 1 + torch/nn/modules/padding.py | 1 + torch/nn/modules/rnn.py | 1 + torch/nn/modules/sparse.py | 1 + torch/nn/modules/transformer.py | 1 + torch/nn/modules/upsampling.py | 1 + torch/nn/modules/utils.py | 1 + torch/nn/parallel/__init__.py | 1 + torch/nn/parallel/comm.py | 1 + torch/nn/parallel/data_parallel.py | 1 + torch/nn/parallel/distributed.py | 1 + torch/nn/parallel/scatter_gather.py | 1 + torch/nn/parameter.pyi | 1 + torch/nn/utils/_deprecation_utils.py | 1 + torch/nn/utils/_expanded_weights/conv_expanded_weights.py | 1 + torch/nn/utils/_expanded_weights/conv_utils.py | 1 + torch/nn/utils/_expanded_weights/embedding_expanded_weights.py | 1 + torch/nn/utils/_expanded_weights/expanded_weights_impl.py | 1 + torch/nn/utils/_expanded_weights/expanded_weights_utils.py | 1 + torch/nn/utils/_expanded_weights/group_norm_expanded_weights.py | 1 + .../nn/utils/_expanded_weights/instance_norm_expanded_weights.py | 1 + torch/nn/utils/_expanded_weights/layer_norm_expanded_weights.py | 1 + torch/nn/utils/_expanded_weights/linear_expanded_weights.py | 1 + torch/nn/utils/_per_sample_grad.py | 1 + torch/nn/utils/clip_grad.py | 1 + torch/nn/utils/init.py | 1 + torch/nn/utils/memory_format.py | 1 + torch/nn/utils/parametrizations.py | 1 + torch/nn/utils/parametrize.py | 1 + torch/nn/utils/prune.py | 1 + torch/nn/utils/rnn.pyi | 1 + torch/nn/utils/spectral_norm.py | 1 + torch/nn/utils/stateless.py | 1 + torch/nn/utils/weight_norm.py | 1 + torch/onnx/__init__.py | 1 + torch/onnx/_deprecation.py | 1 + torch/onnx/_globals.py | 1 + torch/onnx/_internal/_beartype.py | 1 + torch/onnx/_internal/diagnostics/_diagnostic.py | 1 + torch/onnx/_internal/diagnostics/_rules.py | 1 + torch/onnx/_internal/diagnostics/infra/_infra.py | 1 + torch/onnx/_internal/diagnostics/infra/context.py | 1 + torch/onnx/_internal/diagnostics/infra/decorator.py | 1 + torch/onnx/_internal/exporter.py | 1 + torch/onnx/_internal/fx/_pass.py | 1 + torch/onnx/_internal/fx/analysis/unsupported_nodes.py | 1 + torch/onnx/_internal/fx/decomposition_skip.py | 1 + torch/onnx/_internal/fx/decomposition_table.py | 1 + torch/onnx/_internal/fx/diagnostics.py | 1 + torch/onnx/_internal/fx/dynamo_graph_extractor.py | 1 + torch/onnx/_internal/fx/fx_onnx_interpreter.py | 1 + torch/onnx/_internal/fx/fx_symbolic_graph_extractor.py | 1 + torch/onnx/_internal/fx/onnxfunction_dispatcher.py | 1 + torch/onnx/_internal/fx/op_validation.py | 1 + torch/onnx/_internal/fx/passes/_utils.py | 1 + torch/onnx/_internal/fx/passes/decomp.py | 1 + torch/onnx/_internal/fx/passes/functionalization.py | 1 + torch/onnx/_internal/fx/passes/modularization.py | 1 + torch/onnx/_internal/fx/passes/readability.py | 1 + torch/onnx/_internal/fx/passes/type_promotion.py | 1 + torch/onnx/_internal/fx/passes/virtualization.py | 1 + torch/onnx/_internal/fx/patcher.py | 1 + torch/onnx/_internal/fx/serialization.py | 1 + torch/onnx/_internal/fx/torch_export_graph_extractor.py | 1 + torch/onnx/_internal/fx/type_utils.py | 1 + torch/onnx/_internal/io_adapter.py | 1 + torch/onnx/_internal/jit_utils.py | 1 + torch/onnx/_internal/onnx_proto_utils.py | 1 + torch/onnx/_internal/onnxruntime.py | 1 + torch/onnx/_internal/registration.py | 1 + torch/onnx/_onnx_supported_ops.py | 1 + torch/onnx/_type_utils.py | 1 + torch/onnx/operators.py | 1 + torch/onnx/symbolic_caffe2.py | 1 + torch/onnx/symbolic_helper.py | 1 + torch/onnx/symbolic_opset10.py | 1 + torch/onnx/symbolic_opset11.py | 1 + torch/onnx/symbolic_opset12.py | 1 + torch/onnx/symbolic_opset13.py | 1 + torch/onnx/symbolic_opset14.py | 1 + torch/onnx/symbolic_opset15.py | 1 + torch/onnx/symbolic_opset16.py | 1 + torch/onnx/symbolic_opset17.py | 1 + torch/onnx/symbolic_opset18.py | 1 + torch/onnx/symbolic_opset20.py | 1 + torch/onnx/symbolic_opset7.py | 1 + torch/onnx/symbolic_opset8.py | 1 + torch/onnx/symbolic_opset9.py | 1 + torch/onnx/utils.py | 1 + torch/onnx/verification.py | 1 + torch/optim/_functional.py | 1 + torch/optim/adadelta.py | 1 + torch/optim/adagrad.py | 1 + torch/optim/adam.py | 1 + torch/optim/adamax.py | 1 + torch/optim/adamw.py | 1 + torch/optim/asgd.py | 1 + torch/optim/lbfgs.py | 1 + torch/optim/lr_scheduler.py | 1 + torch/optim/nadam.py | 1 + torch/optim/optimizer.py | 1 + torch/optim/radam.py | 1 + torch/optim/rmsprop.py | 1 + torch/optim/rprop.py | 1 + torch/optim/sgd.py | 1 + torch/optim/sparse_adam.py | 1 + torch/optim/swa_utils.py | 1 + torch/package/_digraph.py | 1 + torch/package/_directory_reader.py | 1 + torch/package/_importlib.py | 1 + torch/package/_mangling.py | 1 + torch/package/_mock.py | 1 + 128 files changed, 128 insertions(+) diff --git a/torch/nn/backends/thnn.py b/torch/nn/backends/thnn.py index 5250b4bff167..3cb0f3ff57e2 100644 --- a/torch/nn/backends/thnn.py +++ b/torch/nn/backends/thnn.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # this is for historical pickle deserialization, it is not used otherwise def _get_thnn_function_backend(): diff --git a/torch/nn/cpp.py b/torch/nn/cpp.py index a08c7b314100..98a61bfb7c42 100644 --- a/torch/nn/cpp.py +++ b/torch/nn/cpp.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Functionality for Python <-> C++ frontend inter-op.""" from torch import nn diff --git a/torch/nn/grad.py b/torch/nn/grad.py index 660c87fb4133..dbd38fcdd38c 100644 --- a/torch/nn/grad.py +++ b/torch/nn/grad.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Gradient interface.""" import torch diff --git a/torch/nn/init.py b/torch/nn/init.py index f5be081e7dd0..b3179abb4937 100644 --- a/torch/nn/init.py +++ b/torch/nn/init.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """This file contains utilities for initializing neural network parameters.""" import math import warnings diff --git a/torch/nn/modules/_functions.py b/torch/nn/modules/_functions.py index 669448ce4fda..0e19faa99e5c 100644 --- a/torch/nn/modules/_functions.py +++ b/torch/nn/modules/_functions.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch import torch.distributed as dist diff --git a/torch/nn/modules/activation.py b/torch/nn/modules/activation.py index 5dec6f9578b1..3d8b65175956 100644 --- a/torch/nn/modules/activation.py +++ b/torch/nn/modules/activation.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import warnings from typing import Optional, Tuple diff --git a/torch/nn/modules/adaptive.py b/torch/nn/modules/adaptive.py index 83b37696c8a7..a6c2da5f596f 100644 --- a/torch/nn/modules/adaptive.py +++ b/torch/nn/modules/adaptive.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from collections import namedtuple diff --git a/torch/nn/modules/batchnorm.py b/torch/nn/modules/batchnorm.py index 3c48e56d5e6e..75c8b5504d46 100644 --- a/torch/nn/modules/batchnorm.py +++ b/torch/nn/modules/batchnorm.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import Optional, Any import torch diff --git a/torch/nn/modules/container.py b/torch/nn/modules/container.py index 775a826d69cc..c82d8d7d3037 100644 --- a/torch/nn/modules/container.py +++ b/torch/nn/modules/container.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from collections import OrderedDict, abc as container_abcs from itertools import chain, islice import operator diff --git a/torch/nn/modules/conv.py b/torch/nn/modules/conv.py index 4ab4c8bff9fc..fb6a1557aa71 100644 --- a/torch/nn/modules/conv.py +++ b/torch/nn/modules/conv.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import math import torch diff --git a/torch/nn/modules/flatten.py b/torch/nn/modules/flatten.py index eaf62d5bbeea..f1c44fd350d1 100644 --- a/torch/nn/modules/flatten.py +++ b/torch/nn/modules/flatten.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from .module import Module from typing import Tuple, Union diff --git a/torch/nn/modules/instancenorm.py b/torch/nn/modules/instancenorm.py index ae187e98b7e6..e6a3e1c0a3a1 100644 --- a/torch/nn/modules/instancenorm.py +++ b/torch/nn/modules/instancenorm.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import warnings from torch import Tensor diff --git a/torch/nn/modules/lazy.py b/torch/nn/modules/lazy.py index c4b7459c4acd..f4be1b7db706 100644 --- a/torch/nn/modules/lazy.py +++ b/torch/nn/modules/lazy.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import itertools from typing import Protocol, Optional, Type, Any diff --git a/torch/nn/modules/linear.py b/torch/nn/modules/linear.py index 54981596f7ee..be2739462399 100644 --- a/torch/nn/modules/linear.py +++ b/torch/nn/modules/linear.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import math from typing import Any diff --git a/torch/nn/modules/loss.py b/torch/nn/modules/loss.py index 4324c1df144d..497da8218506 100644 --- a/torch/nn/modules/loss.py +++ b/torch/nn/modules/loss.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from .distance import PairwiseDistance from .module import Module from .. import functional as F diff --git a/torch/nn/modules/module.py b/torch/nn/modules/module.py index ffd429cc06f2..f803d3f02a17 100644 --- a/torch/nn/modules/module.py +++ b/torch/nn/modules/module.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from collections import OrderedDict, namedtuple import itertools import warnings diff --git a/torch/nn/modules/normalization.py b/torch/nn/modules/normalization.py index 97c9c307c5d9..d503409d53a1 100644 --- a/torch/nn/modules/normalization.py +++ b/torch/nn/modules/normalization.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch import numbers from torch.nn.parameter import Parameter diff --git a/torch/nn/modules/padding.py b/torch/nn/modules/padding.py index 0aecca58c305..4b29fbf1c8f4 100644 --- a/torch/nn/modules/padding.py +++ b/torch/nn/modules/padding.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from .module import Module from .utils import _pair, _quadruple, _ntuple from .. import functional as F diff --git a/torch/nn/modules/rnn.py b/torch/nn/modules/rnn.py index b4bdd7824474..8ba4f9f08319 100644 --- a/torch/nn/modules/rnn.py +++ b/torch/nn/modules/rnn.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import math import warnings import numbers diff --git a/torch/nn/modules/sparse.py b/torch/nn/modules/sparse.py index f053a0c8f3c2..512b17d03222 100644 --- a/torch/nn/modules/sparse.py +++ b/torch/nn/modules/sparse.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import Optional import torch diff --git a/torch/nn/modules/transformer.py b/torch/nn/modules/transformer.py index 3c9a8547df32..f5980cd6b1e8 100644 --- a/torch/nn/modules/transformer.py +++ b/torch/nn/modules/transformer.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import copy from typing import Optional, Any, Union, Callable diff --git a/torch/nn/modules/upsampling.py b/torch/nn/modules/upsampling.py index da9b23add18d..7d674da0d5c3 100644 --- a/torch/nn/modules/upsampling.py +++ b/torch/nn/modules/upsampling.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from .module import Module from .. import functional as F diff --git a/torch/nn/modules/utils.py b/torch/nn/modules/utils.py index 019dabe3e533..4a051ed1eba5 100644 --- a/torch/nn/modules/utils.py +++ b/torch/nn/modules/utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import collections from itertools import repeat from typing import List, Dict, Any diff --git a/torch/nn/parallel/__init__.py b/torch/nn/parallel/__init__.py index adcd6bd838eb..8f08e5099d8b 100644 --- a/torch/nn/parallel/__init__.py +++ b/torch/nn/parallel/__init__.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing_extensions import deprecated from .parallel_apply import parallel_apply diff --git a/torch/nn/parallel/comm.py b/torch/nn/parallel/comm.py index 22cf80bd64e2..b907de4004b1 100644 --- a/torch/nn/parallel/comm.py +++ b/torch/nn/parallel/comm.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import warnings import torch from torch.cuda import nccl diff --git a/torch/nn/parallel/data_parallel.py b/torch/nn/parallel/data_parallel.py index 4471cee6f379..3980706a932a 100644 --- a/torch/nn/parallel/data_parallel.py +++ b/torch/nn/parallel/data_parallel.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import operator import torch import warnings diff --git a/torch/nn/parallel/distributed.py b/torch/nn/parallel/distributed.py index 37b6501d2c9c..c71c838cfb85 100644 --- a/torch/nn/parallel/distributed.py +++ b/torch/nn/parallel/distributed.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import copy import functools import inspect diff --git a/torch/nn/parallel/scatter_gather.py b/torch/nn/parallel/scatter_gather.py index f6fb9d47ecbf..73e753760e72 100644 --- a/torch/nn/parallel/scatter_gather.py +++ b/torch/nn/parallel/scatter_gather.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from typing import Any, Dict, List, Optional, Sequence, Tuple, TypeVar, Union, overload from typing_extensions import deprecated diff --git a/torch/nn/parameter.pyi b/torch/nn/parameter.pyi index 219bb6d4efa2..221ffacc3520 100644 --- a/torch/nn/parameter.pyi +++ b/torch/nn/parameter.pyi @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import builtins from typing import Optional, Tuple diff --git a/torch/nn/utils/_deprecation_utils.py b/torch/nn/utils/_deprecation_utils.py index 1b2a9b6e29f2..9910db96e66c 100644 --- a/torch/nn/utils/_deprecation_utils.py +++ b/torch/nn/utils/_deprecation_utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import List, Callable import importlib import warnings diff --git a/torch/nn/utils/_expanded_weights/conv_expanded_weights.py b/torch/nn/utils/_expanded_weights/conv_expanded_weights.py index c10ccb90ae92..147346796d1f 100644 --- a/torch/nn/utils/_expanded_weights/conv_expanded_weights.py +++ b/torch/nn/utils/_expanded_weights/conv_expanded_weights.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch import torch.nn.functional as F diff --git a/torch/nn/utils/_expanded_weights/conv_utils.py b/torch/nn/utils/_expanded_weights/conv_utils.py index b675e3b892bd..2836809d40be 100644 --- a/torch/nn/utils/_expanded_weights/conv_utils.py +++ b/torch/nn/utils/_expanded_weights/conv_utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch import torch.nn.functional as F diff --git a/torch/nn/utils/_expanded_weights/embedding_expanded_weights.py b/torch/nn/utils/_expanded_weights/embedding_expanded_weights.py index c7956a3a1b1f..593fa9e5eed7 100644 --- a/torch/nn/utils/_expanded_weights/embedding_expanded_weights.py +++ b/torch/nn/utils/_expanded_weights/embedding_expanded_weights.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch import torch.nn.functional as F from .expanded_weights_impl import implements_per_sample_grads diff --git a/torch/nn/utils/_expanded_weights/expanded_weights_impl.py b/torch/nn/utils/_expanded_weights/expanded_weights_impl.py index 94e6041c6de5..664e65cc7d90 100644 --- a/torch/nn/utils/_expanded_weights/expanded_weights_impl.py +++ b/torch/nn/utils/_expanded_weights/expanded_weights_impl.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from contextlib import contextmanager import torch diff --git a/torch/nn/utils/_expanded_weights/expanded_weights_utils.py b/torch/nn/utils/_expanded_weights/expanded_weights_utils.py index 249dbe591204..840be6a163f5 100644 --- a/torch/nn/utils/_expanded_weights/expanded_weights_utils.py +++ b/torch/nn/utils/_expanded_weights/expanded_weights_utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import Optional import torch diff --git a/torch/nn/utils/_expanded_weights/group_norm_expanded_weights.py b/torch/nn/utils/_expanded_weights/group_norm_expanded_weights.py index fe29b1eafbe2..6e2919803e4f 100644 --- a/torch/nn/utils/_expanded_weights/group_norm_expanded_weights.py +++ b/torch/nn/utils/_expanded_weights/group_norm_expanded_weights.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from functools import reduce import operator import torch diff --git a/torch/nn/utils/_expanded_weights/instance_norm_expanded_weights.py b/torch/nn/utils/_expanded_weights/instance_norm_expanded_weights.py index f3e68b940660..1d0f40c54081 100644 --- a/torch/nn/utils/_expanded_weights/instance_norm_expanded_weights.py +++ b/torch/nn/utils/_expanded_weights/instance_norm_expanded_weights.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from functools import partial import torch import torch.nn.functional as F diff --git a/torch/nn/utils/_expanded_weights/layer_norm_expanded_weights.py b/torch/nn/utils/_expanded_weights/layer_norm_expanded_weights.py index f2ead2d4c08f..b18c284cd7cf 100644 --- a/torch/nn/utils/_expanded_weights/layer_norm_expanded_weights.py +++ b/torch/nn/utils/_expanded_weights/layer_norm_expanded_weights.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch import torch.nn.functional as F diff --git a/torch/nn/utils/_expanded_weights/linear_expanded_weights.py b/torch/nn/utils/_expanded_weights/linear_expanded_weights.py index c2cbae63f336..6a80c1dc9219 100644 --- a/torch/nn/utils/_expanded_weights/linear_expanded_weights.py +++ b/torch/nn/utils/_expanded_weights/linear_expanded_weights.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch import torch.nn.functional as F from .expanded_weights_impl import implements_per_sample_grads diff --git a/torch/nn/utils/_per_sample_grad.py b/torch/nn/utils/_per_sample_grad.py index 0644ab5d2535..a64942083f0c 100644 --- a/torch/nn/utils/_per_sample_grad.py +++ b/torch/nn/utils/_per_sample_grad.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import functools import torch diff --git a/torch/nn/utils/clip_grad.py b/torch/nn/utils/clip_grad.py index 4ac8a4e7445b..cc83353909f9 100644 --- a/torch/nn/utils/clip_grad.py +++ b/torch/nn/utils/clip_grad.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import functools from typing import Union, Iterable, List, Dict, Tuple, Optional, cast from typing_extensions import deprecated diff --git a/torch/nn/utils/init.py b/torch/nn/utils/init.py index 416ad0db8ef7..4768d3009005 100644 --- a/torch/nn/utils/init.py +++ b/torch/nn/utils/init.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import inspect import torch diff --git a/torch/nn/utils/memory_format.py b/torch/nn/utils/memory_format.py index c8fc22bea51c..aaa2b6bfb198 100644 --- a/torch/nn/utils/memory_format.py +++ b/torch/nn/utils/memory_format.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch diff --git a/torch/nn/utils/parametrizations.py b/torch/nn/utils/parametrizations.py index f9b25bcac0cb..cf686504072f 100644 --- a/torch/nn/utils/parametrizations.py +++ b/torch/nn/utils/parametrizations.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from enum import Enum, auto import torch diff --git a/torch/nn/utils/parametrize.py b/torch/nn/utils/parametrize.py index f512b7c3b22a..b828c1d230f1 100644 --- a/torch/nn/utils/parametrize.py +++ b/torch/nn/utils/parametrize.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch.__future__ import get_swap_module_params_on_conversion from torch.nn.modules.container import ModuleList, ModuleDict, Module diff --git a/torch/nn/utils/prune.py b/torch/nn/utils/prune.py index 0375106d69e0..b0e1f99a6c1f 100644 --- a/torch/nn/utils/prune.py +++ b/torch/nn/utils/prune.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs r"""Pruning methods.""" import numbers from abc import ABC, abstractmethod diff --git a/torch/nn/utils/rnn.pyi b/torch/nn/utils/rnn.pyi index fd033d8888be..9ffc650714ff 100644 --- a/torch/nn/utils/rnn.pyi +++ b/torch/nn/utils/rnn.pyi @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import Any, Iterable, NamedTuple, Optional, overload, Sequence, Tuple, Union from typing_extensions import Self diff --git a/torch/nn/utils/spectral_norm.py b/torch/nn/utils/spectral_norm.py index bda54b9a1222..fcc4bbf5fe29 100644 --- a/torch/nn/utils/spectral_norm.py +++ b/torch/nn/utils/spectral_norm.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Spectral Normalization from https://arxiv.org/abs/1802.05957.""" import torch from torch.nn.functional import normalize diff --git a/torch/nn/utils/stateless.py b/torch/nn/utils/stateless.py index 660a1a484ebb..07b03c04a120 100644 --- a/torch/nn/utils/stateless.py +++ b/torch/nn/utils/stateless.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import contextlib from collections import defaultdict from typing import Any, Dict, Iterator, Optional, Set, Tuple, Union diff --git a/torch/nn/utils/weight_norm.py b/torch/nn/utils/weight_norm.py index 6cfe4b3e526d..abb21a7b4672 100644 --- a/torch/nn/utils/weight_norm.py +++ b/torch/nn/utils/weight_norm.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs r"""Weight Normalization from https://arxiv.org/abs/1602.07868.""" from torch.nn.parameter import Parameter, UninitializedParameter from torch import _weight_norm, norm_except_dim diff --git a/torch/onnx/__init__.py b/torch/onnx/__init__.py index 4d16ef09c8b3..2b2f2bdae0de 100644 --- a/torch/onnx/__init__.py +++ b/torch/onnx/__init__.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from torch import _C from torch._C import _onnx as _C_onnx from torch._C._onnx import ( diff --git a/torch/onnx/_deprecation.py b/torch/onnx/_deprecation.py index 0fd2cd764fc9..1f78dd55bd5d 100644 --- a/torch/onnx/_deprecation.py +++ b/torch/onnx/_deprecation.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Utility for deprecating functions.""" import functools diff --git a/torch/onnx/_globals.py b/torch/onnx/_globals.py index f827d12be7fb..22c05075dba8 100644 --- a/torch/onnx/_globals.py +++ b/torch/onnx/_globals.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Globals used internally by the ONNX exporter. Do not use this module outside of `torch.onnx` and its tests. diff --git a/torch/onnx/_internal/_beartype.py b/torch/onnx/_internal/_beartype.py index 25e1c1cb7299..1e5006fb56c1 100644 --- a/torch/onnx/_internal/_beartype.py +++ b/torch/onnx/_internal/_beartype.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """An internal wrapper for the beartype library. The module returns a no-op decorator when the beartype library is not installed. diff --git a/torch/onnx/_internal/diagnostics/_diagnostic.py b/torch/onnx/_internal/diagnostics/_diagnostic.py index 09079d5e9c4a..e5b22b07539c 100644 --- a/torch/onnx/_internal/diagnostics/_diagnostic.py +++ b/torch/onnx/_internal/diagnostics/_diagnostic.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Diagnostic components for TorchScript based ONNX export, i.e. `torch.onnx.export`.""" from __future__ import annotations diff --git a/torch/onnx/_internal/diagnostics/_rules.py b/torch/onnx/_internal/diagnostics/_rules.py index 0bfda96c5bce..3b2ca727d0d1 100644 --- a/torch/onnx/_internal/diagnostics/_rules.py +++ b/torch/onnx/_internal/diagnostics/_rules.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """ GENERATED CODE - DO NOT EDIT DIRECTLY This file is generated by gen_diagnostics.py. diff --git a/torch/onnx/_internal/diagnostics/infra/_infra.py b/torch/onnx/_internal/diagnostics/infra/_infra.py index c118f3e5ae14..e51c99a3151b 100644 --- a/torch/onnx/_internal/diagnostics/infra/_infra.py +++ b/torch/onnx/_internal/diagnostics/infra/_infra.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """This file defines an additional layer of abstraction on top of the SARIF OM.""" from __future__ import annotations diff --git a/torch/onnx/_internal/diagnostics/infra/context.py b/torch/onnx/_internal/diagnostics/infra/context.py index 6106a42467c1..f670adc2cae2 100644 --- a/torch/onnx/_internal/diagnostics/infra/context.py +++ b/torch/onnx/_internal/diagnostics/infra/context.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """A diagnostic context based on SARIF.""" from __future__ import annotations diff --git a/torch/onnx/_internal/diagnostics/infra/decorator.py b/torch/onnx/_internal/diagnostics/infra/decorator.py index 0ac803815703..67066f5da500 100644 --- a/torch/onnx/_internal/diagnostics/infra/decorator.py +++ b/torch/onnx/_internal/diagnostics/infra/decorator.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import functools diff --git a/torch/onnx/_internal/exporter.py b/torch/onnx/_internal/exporter.py index cf9f1cd747e5..ac62de0214dd 100644 --- a/torch/onnx/_internal/exporter.py +++ b/torch/onnx/_internal/exporter.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import ( # for onnx.ModelProto (ONNXProgram) and onnxruntime (ONNXRuntimeOptions) annotations, ) diff --git a/torch/onnx/_internal/fx/_pass.py b/torch/onnx/_internal/fx/_pass.py index 69fa023b9add..cef8e045f7fb 100644 --- a/torch/onnx/_internal/fx/_pass.py +++ b/torch/onnx/_internal/fx/_pass.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import abc diff --git a/torch/onnx/_internal/fx/analysis/unsupported_nodes.py b/torch/onnx/_internal/fx/analysis/unsupported_nodes.py index 5da0dbed3d91..deec2a85e1da 100644 --- a/torch/onnx/_internal/fx/analysis/unsupported_nodes.py +++ b/torch/onnx/_internal/fx/analysis/unsupported_nodes.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import dataclasses diff --git a/torch/onnx/_internal/fx/decomposition_skip.py b/torch/onnx/_internal/fx/decomposition_skip.py index 7fb971a3307a..646e0765f190 100644 --- a/torch/onnx/_internal/fx/decomposition_skip.py +++ b/torch/onnx/_internal/fx/decomposition_skip.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """A context manager that disables the decomposition of certain ops during dynamo tracing. The approach is to temporarily hijack the operator callable with PT2 custom operator. diff --git a/torch/onnx/_internal/fx/decomposition_table.py b/torch/onnx/_internal/fx/decomposition_table.py index 5cb9be6da79d..027d580717af 100644 --- a/torch/onnx/_internal/fx/decomposition_table.py +++ b/torch/onnx/_internal/fx/decomposition_table.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Dispatcher for AtenLib functions from onnx-script.""" from __future__ import annotations diff --git a/torch/onnx/_internal/fx/diagnostics.py b/torch/onnx/_internal/fx/diagnostics.py index 11e4c79f2e1a..0be358751c11 100644 --- a/torch/onnx/_internal/fx/diagnostics.py +++ b/torch/onnx/_internal/fx/diagnostics.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import dataclasses diff --git a/torch/onnx/_internal/fx/dynamo_graph_extractor.py b/torch/onnx/_internal/fx/dynamo_graph_extractor.py index fbc7d92e043f..1379a0613895 100644 --- a/torch/onnx/_internal/fx/dynamo_graph_extractor.py +++ b/torch/onnx/_internal/fx/dynamo_graph_extractor.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # NOTE: This file is referenced by name at # /opt/pytorch/torch/_dynamo/eval_frame.py::DONT_WRAP_FILES. # introduced by https://github.com/pytorch/pytorch/pull/98894. diff --git a/torch/onnx/_internal/fx/fx_onnx_interpreter.py b/torch/onnx/_internal/fx/fx_onnx_interpreter.py index 50ead7556f37..a0be86e11d6b 100644 --- a/torch/onnx/_internal/fx/fx_onnx_interpreter.py +++ b/torch/onnx/_internal/fx/fx_onnx_interpreter.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import inspect diff --git a/torch/onnx/_internal/fx/fx_symbolic_graph_extractor.py b/torch/onnx/_internal/fx/fx_symbolic_graph_extractor.py index 18dc84e19585..1d7d191cbd25 100644 --- a/torch/onnx/_internal/fx/fx_symbolic_graph_extractor.py +++ b/torch/onnx/_internal/fx/fx_symbolic_graph_extractor.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import functools diff --git a/torch/onnx/_internal/fx/onnxfunction_dispatcher.py b/torch/onnx/_internal/fx/onnxfunction_dispatcher.py index 2986ac279ec3..3886733093a3 100644 --- a/torch/onnx/_internal/fx/onnxfunction_dispatcher.py +++ b/torch/onnx/_internal/fx/onnxfunction_dispatcher.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Dispatcher for AtenLib functions from onnx-script.""" from __future__ import annotations diff --git a/torch/onnx/_internal/fx/op_validation.py b/torch/onnx/_internal/fx/op_validation.py index b306bc2141de..01161aee25ea 100644 --- a/torch/onnx/_internal/fx/op_validation.py +++ b/torch/onnx/_internal/fx/op_validation.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Module for handling op-level validation during exporting.""" from __future__ import annotations diff --git a/torch/onnx/_internal/fx/passes/_utils.py b/torch/onnx/_internal/fx/passes/_utils.py index 92a883469a52..6e49bccfcfaf 100644 --- a/torch/onnx/_internal/fx/passes/_utils.py +++ b/torch/onnx/_internal/fx/passes/_utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Common utility functions for FX passes. These functions should NOT be directly invoked outside of `passes` package. diff --git a/torch/onnx/_internal/fx/passes/decomp.py b/torch/onnx/_internal/fx/passes/decomp.py index b9a131b97466..5185b1152485 100644 --- a/torch/onnx/_internal/fx/passes/decomp.py +++ b/torch/onnx/_internal/fx/passes/decomp.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import contextlib diff --git a/torch/onnx/_internal/fx/passes/functionalization.py b/torch/onnx/_internal/fx/passes/functionalization.py index 21f2691cbb8e..dfdee6e88c85 100644 --- a/torch/onnx/_internal/fx/passes/functionalization.py +++ b/torch/onnx/_internal/fx/passes/functionalization.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import contextlib diff --git a/torch/onnx/_internal/fx/passes/modularization.py b/torch/onnx/_internal/fx/passes/modularization.py index b7c3b90cab66..6e1352f73046 100644 --- a/torch/onnx/_internal/fx/passes/modularization.py +++ b/torch/onnx/_internal/fx/passes/modularization.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import abc diff --git a/torch/onnx/_internal/fx/passes/readability.py b/torch/onnx/_internal/fx/passes/readability.py index 64887ad2ee6e..2b3518b79ea6 100644 --- a/torch/onnx/_internal/fx/passes/readability.py +++ b/torch/onnx/_internal/fx/passes/readability.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations from typing import Dict, List, Sequence, Tuple, Union diff --git a/torch/onnx/_internal/fx/passes/type_promotion.py b/torch/onnx/_internal/fx/passes/type_promotion.py index 944cad4acf1c..bc584ff32925 100644 --- a/torch/onnx/_internal/fx/passes/type_promotion.py +++ b/torch/onnx/_internal/fx/passes/type_promotion.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # Owner(s): ["module: onnx"] from __future__ import annotations diff --git a/torch/onnx/_internal/fx/passes/virtualization.py b/torch/onnx/_internal/fx/passes/virtualization.py index 66ca69d7a70f..cd77b6eec18b 100644 --- a/torch/onnx/_internal/fx/passes/virtualization.py +++ b/torch/onnx/_internal/fx/passes/virtualization.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations from typing import List, Optional, Tuple diff --git a/torch/onnx/_internal/fx/patcher.py b/torch/onnx/_internal/fx/patcher.py index ee919eae00d1..dbd8fb591126 100644 --- a/torch/onnx/_internal/fx/patcher.py +++ b/torch/onnx/_internal/fx/patcher.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import copy import functools import io diff --git a/torch/onnx/_internal/fx/serialization.py b/torch/onnx/_internal/fx/serialization.py index 726bf4219330..5739442163a3 100644 --- a/torch/onnx/_internal/fx/serialization.py +++ b/torch/onnx/_internal/fx/serialization.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import io diff --git a/torch/onnx/_internal/fx/torch_export_graph_extractor.py b/torch/onnx/_internal/fx/torch_export_graph_extractor.py index fb3f0e99a6d6..a825e466f1aa 100644 --- a/torch/onnx/_internal/fx/torch_export_graph_extractor.py +++ b/torch/onnx/_internal/fx/torch_export_graph_extractor.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # NOTE: This file is referenced by name at # /opt/pytorch/torch/_dynamo/eval_frame.py::DONT_WRAP_FILES. # introduced by https://github.com/pytorch/pytorch/pull/98894. diff --git a/torch/onnx/_internal/fx/type_utils.py b/torch/onnx/_internal/fx/type_utils.py index 90abdc244d99..3aac02a51214 100644 --- a/torch/onnx/_internal/fx/type_utils.py +++ b/torch/onnx/_internal/fx/type_utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Utilities for converting and operating on ONNX, JIT and torch types.""" from __future__ import annotations diff --git a/torch/onnx/_internal/io_adapter.py b/torch/onnx/_internal/io_adapter.py index 2f8c9202d7bb..12100d0f489c 100644 --- a/torch/onnx/_internal/io_adapter.py +++ b/torch/onnx/_internal/io_adapter.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import inspect diff --git a/torch/onnx/_internal/jit_utils.py b/torch/onnx/_internal/jit_utils.py index 719f4b0c16e8..13ae4209da5d 100644 --- a/torch/onnx/_internal/jit_utils.py +++ b/torch/onnx/_internal/jit_utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Utilities for manipulating the torch.Graph object and the torchscript.""" from __future__ import annotations diff --git a/torch/onnx/_internal/onnx_proto_utils.py b/torch/onnx/_internal/onnx_proto_utils.py index 278af3feacc6..40eb1bd8d64e 100644 --- a/torch/onnx/_internal/onnx_proto_utils.py +++ b/torch/onnx/_internal/onnx_proto_utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Utilities for manipulating the onnx and onnx-script dependencies and ONNX proto.""" from __future__ import annotations diff --git a/torch/onnx/_internal/onnxruntime.py b/torch/onnx/_internal/onnxruntime.py index aa3495ee5ac5..d8a7e55e8f9e 100644 --- a/torch/onnx/_internal/onnxruntime.py +++ b/torch/onnx/_internal/onnxruntime.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import dataclasses import importlib import logging diff --git a/torch/onnx/_internal/registration.py b/torch/onnx/_internal/registration.py index 3b2e68e1e40a..f051708f864d 100644 --- a/torch/onnx/_internal/registration.py +++ b/torch/onnx/_internal/registration.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Module for handling symbolic function registration.""" import warnings diff --git a/torch/onnx/_onnx_supported_ops.py b/torch/onnx/_onnx_supported_ops.py index 2611b0d81e9b..e2707298d6d9 100644 --- a/torch/onnx/_onnx_supported_ops.py +++ b/torch/onnx/_onnx_supported_ops.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import inspect from typing import Dict, List, Union diff --git a/torch/onnx/_type_utils.py b/torch/onnx/_type_utils.py index d13232507317..d9b647c807f3 100644 --- a/torch/onnx/_type_utils.py +++ b/torch/onnx/_type_utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Utilities for converting and operating on ONNX, JIT and torch types.""" from __future__ import annotations diff --git a/torch/onnx/operators.py b/torch/onnx/operators.py index 489010519980..1e7532e8451d 100644 --- a/torch/onnx/operators.py +++ b/torch/onnx/operators.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs r"""This file provides a location for operators that help exporting models via onnx. E.g. `shape_as_tensor` and `reshape_from_tensor_shape` diff --git a/torch/onnx/symbolic_caffe2.py b/torch/onnx/symbolic_caffe2.py index 3398fcd2fe10..ed2dc6cd9fdb 100644 --- a/torch/onnx/symbolic_caffe2.py +++ b/torch/onnx/symbolic_caffe2.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import importlib import inspect diff --git a/torch/onnx/symbolic_helper.py b/torch/onnx/symbolic_helper.py index 4430babaef00..676c3d68048b 100644 --- a/torch/onnx/symbolic_helper.py +++ b/torch/onnx/symbolic_helper.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import functools diff --git a/torch/onnx/symbolic_opset10.py b/torch/onnx/symbolic_opset10.py index 6fd576822e2c..e9ba8b4015f2 100644 --- a/torch/onnx/symbolic_opset10.py +++ b/torch/onnx/symbolic_opset10.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import functools diff --git a/torch/onnx/symbolic_opset11.py b/torch/onnx/symbolic_opset11.py index 99d5064ad7a0..e562d5a47567 100644 --- a/torch/onnx/symbolic_opset11.py +++ b/torch/onnx/symbolic_opset11.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """This file exports ONNX ops for opset 11.""" from __future__ import annotations diff --git a/torch/onnx/symbolic_opset12.py b/torch/onnx/symbolic_opset12.py index 130b02a889b0..5a6bf720df36 100644 --- a/torch/onnx/symbolic_opset12.py +++ b/torch/onnx/symbolic_opset12.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import functools diff --git a/torch/onnx/symbolic_opset13.py b/torch/onnx/symbolic_opset13.py index 5bba817bbce0..bb7045c0f58b 100644 --- a/torch/onnx/symbolic_opset13.py +++ b/torch/onnx/symbolic_opset13.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # EDITING THIS FILE? READ THIS FIRST! # see Note [Edit Symbolic Files] in README.md diff --git a/torch/onnx/symbolic_opset14.py b/torch/onnx/symbolic_opset14.py index 1b4b8ee7917c..62e05910dd72 100644 --- a/torch/onnx/symbolic_opset14.py +++ b/torch/onnx/symbolic_opset14.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """This file exports ONNX ops for opset 14. Note [ONNX operators that are added/updated in opset 14] diff --git a/torch/onnx/symbolic_opset15.py b/torch/onnx/symbolic_opset15.py index 4f316a77f62e..793c1cad8fb9 100644 --- a/torch/onnx/symbolic_opset15.py +++ b/torch/onnx/symbolic_opset15.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """This file exports ONNX ops for opset 15. Note [ONNX operators that are added/updated in opset 15] diff --git a/torch/onnx/symbolic_opset16.py b/torch/onnx/symbolic_opset16.py index 24306b475366..cd5829ada850 100644 --- a/torch/onnx/symbolic_opset16.py +++ b/torch/onnx/symbolic_opset16.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """This file exports ONNX ops for opset 16. Note [ONNX Operators that are added/updated in opset 16] diff --git a/torch/onnx/symbolic_opset17.py b/torch/onnx/symbolic_opset17.py index c7720b9e5c9f..44c789017d75 100644 --- a/torch/onnx/symbolic_opset17.py +++ b/torch/onnx/symbolic_opset17.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """This file exports ONNX ops for opset 17. Note [ONNX Operators that are added/updated in opset 17] diff --git a/torch/onnx/symbolic_opset18.py b/torch/onnx/symbolic_opset18.py index d80361dd417f..68e14c987731 100644 --- a/torch/onnx/symbolic_opset18.py +++ b/torch/onnx/symbolic_opset18.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """This file exports ONNX ops for opset 18. Note [ONNX Operators that are added/updated in opset 18] diff --git a/torch/onnx/symbolic_opset20.py b/torch/onnx/symbolic_opset20.py index 9c81bc3e3c49..9557b5f2828e 100644 --- a/torch/onnx/symbolic_opset20.py +++ b/torch/onnx/symbolic_opset20.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """This file exports ONNX ops for opset 20. Note [ONNX Operators that are added/updated in opset 20] diff --git a/torch/onnx/symbolic_opset7.py b/torch/onnx/symbolic_opset7.py index 0537e8a92888..c647ead4e297 100644 --- a/torch/onnx/symbolic_opset7.py +++ b/torch/onnx/symbolic_opset7.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """ Note [ONNX operators that are added/updated from opset 7 to opset 8] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/torch/onnx/symbolic_opset8.py b/torch/onnx/symbolic_opset8.py index b2fbee3b9784..87b4be230e78 100644 --- a/torch/onnx/symbolic_opset8.py +++ b/torch/onnx/symbolic_opset8.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """ Note [ONNX operators that are added/updated from opset 8 to opset 9] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/torch/onnx/symbolic_opset9.py b/torch/onnx/symbolic_opset9.py index adfa538c8f08..f71ef713636a 100644 --- a/torch/onnx/symbolic_opset9.py +++ b/torch/onnx/symbolic_opset9.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """This file exports ONNX ops for opset 9. Opset 9 is supported by ONNX release 1.4.1 diff --git a/torch/onnx/utils.py b/torch/onnx/utils.py index 191df45ac9ef..94a57786a4bd 100644 --- a/torch/onnx/utils.py +++ b/torch/onnx/utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Functions to export models into the ONNX IR format. These models can be loaded with the ONNX library and then diff --git a/torch/onnx/verification.py b/torch/onnx/verification.py index 6b49e7fc72b9..95ed873bf633 100644 --- a/torch/onnx/verification.py +++ b/torch/onnx/verification.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Functions to verify exported ONNX model is functionally equivalent to original PyTorch model. ONNX Runtime is required, and is used as the ONNX backend for export verification. diff --git a/torch/optim/_functional.py b/torch/optim/_functional.py index 4a6198956fb8..a307cc76846d 100644 --- a/torch/optim/_functional.py +++ b/torch/optim/_functional.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs r"""Functional interface.""" import math from typing import List diff --git a/torch/optim/adadelta.py b/torch/optim/adadelta.py index 4d1a4e25319c..eff24f159213 100644 --- a/torch/optim/adadelta.py +++ b/torch/optim/adadelta.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import Any, Dict, List, Optional import torch diff --git a/torch/optim/adagrad.py b/torch/optim/adagrad.py index a95e985b49eb..0b6dfe852d08 100644 --- a/torch/optim/adagrad.py +++ b/torch/optim/adagrad.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import List, Optional import torch diff --git a/torch/optim/adam.py b/torch/optim/adam.py index 1c625682fc34..bff29613175a 100644 --- a/torch/optim/adam.py +++ b/torch/optim/adam.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import List, Optional, Tuple, Union import torch diff --git a/torch/optim/adamax.py b/torch/optim/adamax.py index 005327d8bb88..c2e39b788014 100644 --- a/torch/optim/adamax.py +++ b/torch/optim/adamax.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import List, Optional, Tuple, Union import torch diff --git a/torch/optim/adamw.py b/torch/optim/adamw.py index 707ac17c361c..2292c17f9e0f 100644 --- a/torch/optim/adamw.py +++ b/torch/optim/adamw.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import cast, List, Optional, Tuple, Union import torch diff --git a/torch/optim/asgd.py b/torch/optim/asgd.py index 633a14832282..454772670904 100644 --- a/torch/optim/asgd.py +++ b/torch/optim/asgd.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import List, Optional, Tuple, Union import torch diff --git a/torch/optim/lbfgs.py b/torch/optim/lbfgs.py index e8818cca538c..480b45c84d72 100644 --- a/torch/optim/lbfgs.py +++ b/torch/optim/lbfgs.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import Optional import torch diff --git a/torch/optim/lr_scheduler.py b/torch/optim/lr_scheduler.py index cb7d9738df5a..4a5f162a0b20 100644 --- a/torch/optim/lr_scheduler.py +++ b/torch/optim/lr_scheduler.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import math import types import warnings diff --git a/torch/optim/nadam.py b/torch/optim/nadam.py index fd1f8ab0e718..a4a6d07b2ca8 100644 --- a/torch/optim/nadam.py +++ b/torch/optim/nadam.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import cast, List, Optional, Tuple, Union import torch diff --git a/torch/optim/optimizer.py b/torch/optim/optimizer.py index fc091e273c36..498669e65fbd 100644 --- a/torch/optim/optimizer.py +++ b/torch/optim/optimizer.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import functools import math import warnings diff --git a/torch/optim/radam.py b/torch/optim/radam.py index 619f10493587..d21973caeceb 100644 --- a/torch/optim/radam.py +++ b/torch/optim/radam.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import cast, List, Optional, Tuple, Union import torch diff --git a/torch/optim/rmsprop.py b/torch/optim/rmsprop.py index bdc3ec0b8b3f..30b56779fc75 100644 --- a/torch/optim/rmsprop.py +++ b/torch/optim/rmsprop.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import List, Optional import torch diff --git a/torch/optim/rprop.py b/torch/optim/rprop.py index af1854cc518a..69043b48673e 100644 --- a/torch/optim/rprop.py +++ b/torch/optim/rprop.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import List, Optional, Tuple import torch diff --git a/torch/optim/sgd.py b/torch/optim/sgd.py index 291b4068dd4c..e682d83701d5 100644 --- a/torch/optim/sgd.py +++ b/torch/optim/sgd.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import List, Optional import torch diff --git a/torch/optim/sparse_adam.py b/torch/optim/sparse_adam.py index 88643d1a5646..adb7c17629c2 100644 --- a/torch/optim/sparse_adam.py +++ b/torch/optim/sparse_adam.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import List, Tuple import torch diff --git a/torch/optim/swa_utils.py b/torch/optim/swa_utils.py index 4cfca073af77..440897e6041e 100644 --- a/torch/optim/swa_utils.py +++ b/torch/optim/swa_utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import itertools import math import warnings diff --git a/torch/package/_digraph.py b/torch/package/_digraph.py index f84a51398f00..8b753f7ebdc4 100644 --- a/torch/package/_digraph.py +++ b/torch/package/_digraph.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from collections import deque from typing import List, Set diff --git a/torch/package/_directory_reader.py b/torch/package/_directory_reader.py index cec5333c3e3f..77d629cccce2 100644 --- a/torch/package/_directory_reader.py +++ b/torch/package/_directory_reader.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os.path from glob import glob from typing import cast diff --git a/torch/package/_importlib.py b/torch/package/_importlib.py index fd303b6141e7..9741925315e5 100644 --- a/torch/package/_importlib.py +++ b/torch/package/_importlib.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import _warnings import os.path diff --git a/torch/package/_mangling.py b/torch/package/_mangling.py index 0876d64664a2..7dcf3538631f 100644 --- a/torch/package/_mangling.py +++ b/torch/package/_mangling.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Import mangling. See mangling.md for details. """ diff --git a/torch/package/_mock.py b/torch/package/_mock.py index b0bdb95cc48c..44876b1a1d3f 100644 --- a/torch/package/_mock.py +++ b/torch/package/_mock.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs _magic_methods = [ "__subclasscheck__", "__hex__",