diff --git a/caffe2/perfkernels/hp_emblookup_codegen.py b/caffe2/perfkernels/hp_emblookup_codegen.py index 7e4208caf655..26018c2c002c 100644 --- a/caffe2/perfkernels/hp_emblookup_codegen.py +++ b/caffe2/perfkernels/hp_emblookup_codegen.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import argparse diff --git a/test/test_bundled_images.py b/test/test_bundled_images.py index 73f51d008bb1..c6ed9efe9f64 100644 --- a/test/test_bundled_images.py +++ b/test/test_bundled_images.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 # Owner(s): ["oncall: mobile"] +# mypy: allow-untyped-defs import io diff --git a/test/test_bundled_inputs.py b/test/test_bundled_inputs.py index 2ba1ee847e8b..007fbd32dde4 100644 --- a/test/test_bundled_inputs.py +++ b/test/test_bundled_inputs.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 # Owner(s): ["oncall: mobile"] +# mypy: allow-untyped-defs import io import textwrap diff --git a/test/test_complex.py b/test/test_complex.py index 04fa566bf94f..67e8732dcbe1 100644 --- a/test/test_complex.py +++ b/test/test_complex.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # Owner(s): ["module: complex"] import torch diff --git a/test/test_futures.py b/test/test_futures.py index 33814eda41ea..dd1e79ff83b3 100644 --- a/test/test_futures.py +++ b/test/test_futures.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # Owner(s): ["module: unknown"] import threading diff --git a/test/test_torch.py b/test/test_torch.py index ff573706913f..f252ddf4a574 100644 --- a/test/test_torch.py +++ b/test/test_torch.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # Owner(s): ["module: tests"] import torch diff --git a/test/test_type_hints.py b/test/test_type_hints.py index a4ae1768cd2a..2fba1ba2f9e4 100644 --- a/test/test_type_hints.py +++ b/test/test_type_hints.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # Owner(s): ["module: typing"] import doctest diff --git a/test/test_type_info.py b/test/test_type_info.py index 97bb23e89c99..9160c31b4fb8 100644 --- a/test/test_type_info.py +++ b/test/test_type_info.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # Owner(s): ["module: typing"] from torch.testing._internal.common_utils import ( diff --git a/test/test_utils.py b/test/test_utils.py index 66d66b8874f1..b0435e548311 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # Owner(s): ["module: unknown"] import os diff --git a/torch/_C/_VariableFunctions.pyi.in b/torch/_C/_VariableFunctions.pyi.in index 24f9f0f9e9fb..9476acb75791 100644 --- a/torch/_C/_VariableFunctions.pyi.in +++ b/torch/_C/_VariableFunctions.pyi.in @@ -1,5 +1,6 @@ # ${generated_comment} # mypy: disable-error-code="type-arg" +# mypy: allow-untyped-defs import builtins from typing import ( diff --git a/torch/_C/__init__.pyi.in b/torch/_C/__init__.pyi.in index bcc26350a896..4326cd3c71da 100644 --- a/torch/_C/__init__.pyi.in +++ b/torch/_C/__init__.pyi.in @@ -1,5 +1,6 @@ # ${generated_comment} # mypy: disable-error-code="type-arg" +# mypy: allow-untyped-defs import builtins from enum import Enum, IntEnum diff --git a/torch/_C/_autograd.pyi b/torch/_C/_autograd.pyi index 118d913f6815..05a791725608 100644 --- a/torch/_C/_autograd.pyi +++ b/torch/_C/_autograd.pyi @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from enum import Enum from typing import Any, Callable, List, Optional, Set diff --git a/torch/_C/_distributed_autograd.pyi b/torch/_C/_distributed_autograd.pyi index f4c91304a1b1..dc2a9e9488a9 100644 --- a/torch/_C/_distributed_autograd.pyi +++ b/torch/_C/_distributed_autograd.pyi @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import Any, Dict, List, Set import torch diff --git a/torch/_C/_distributed_c10d.pyi b/torch/_C/_distributed_c10d.pyi index d6f7ae259a88..cffbf22219c8 100644 --- a/torch/_C/_distributed_c10d.pyi +++ b/torch/_C/_distributed_c10d.pyi @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # mypy: disable-error-code="type-arg" from datetime import timedelta from enum import Enum diff --git a/torch/_C/_distributed_rpc.pyi b/torch/_C/_distributed_rpc.pyi index 7909e0b8e33c..ded7061bbd49 100644 --- a/torch/_C/_distributed_rpc.pyi +++ b/torch/_C/_distributed_rpc.pyi @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # mypy: disable-error-code="type-arg" from datetime import timedelta from typing import Any, Dict, Generic, List, Optional, overload, Tuple, Type, TypeVar diff --git a/torch/_C/_dynamo/eval_frame.pyi b/torch/_C/_dynamo/eval_frame.pyi index f3ad6f722827..14321b2f946f 100644 --- a/torch/_C/_dynamo/eval_frame.pyi +++ b/torch/_C/_dynamo/eval_frame.pyi @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import types from typing import List, NewType, Optional diff --git a/torch/_C/_dynamo/guards.pyi b/torch/_C/_dynamo/guards.pyi index 2de2f10cd328..6b1cf00bce41 100644 --- a/torch/_C/_dynamo/guards.pyi +++ b/torch/_C/_dynamo/guards.pyi @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import Any, Dict, List, Optional, Union import torch diff --git a/torch/_C/_functorch.pyi b/torch/_C/_functorch.pyi index 111113221a0c..0180586d0bc3 100644 --- a/torch/_C/_functorch.pyi +++ b/torch/_C/_functorch.pyi @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from enum import Enum from typing import Optional, Tuple diff --git a/torch/_C/_lazy.pyi b/torch/_C/_lazy.pyi index ceaaedee2102..f4f57ee56b34 100644 --- a/torch/_C/_lazy.pyi +++ b/torch/_C/_lazy.pyi @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import List from torch import Tensor diff --git a/torch/_C/_lazy_ts_backend.pyi b/torch/_C/_lazy_ts_backend.pyi index ce833c5ec2e4..b5e69583dbb9 100644 --- a/torch/_C/_lazy_ts_backend.pyi +++ b/torch/_C/_lazy_ts_backend.pyi @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # defined in torch/csrc/lazy/python/init.cpp from typing import Any, List, Tuple diff --git a/torch/_C/_nvtx.pyi b/torch/_C/_nvtx.pyi index f7ff779d8ad7..79c9cc2c4b9b 100644 --- a/torch/_C/_nvtx.pyi +++ b/torch/_C/_nvtx.pyi @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # Defined in torch/csrc/cuda/shared/nvtx.cpp def rangePushA(message: str) -> int: ... def rangePop() -> int: ... diff --git a/torch/_C_flatbuffer/__init__.pyi b/torch/_C_flatbuffer/__init__.pyi index 3a2ff059b0ed..38750ed26aa2 100644 --- a/torch/_C_flatbuffer/__init__.pyi +++ b/torch/_C_flatbuffer/__init__.pyi @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from torch._C import LiteScriptModule, ScriptModule def _load_mobile_module_from_file(filename: str): ... diff --git a/torch/__config__.py b/torch/__config__.py index f7e3e209654a..fdb091032759 100644 --- a/torch/__config__.py +++ b/torch/__config__.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch diff --git a/torch/__init__.py b/torch/__init__.py index 16804ff75898..b07d4ea1c180 100644 --- a/torch/__init__.py +++ b/torch/__init__.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs r""" The torch package contains data structures for multi-dimensional diff --git a/torch/_classes.py b/torch/_classes.py index 870073fea6ea..58b347453524 100644 --- a/torch/_classes.py +++ b/torch/_classes.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import types import torch._C diff --git a/torch/_compile.py b/torch/_compile.py index 2b00415e0eba..0f0f51a3509a 100644 --- a/torch/_compile.py +++ b/torch/_compile.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """ APIs related to torch.compile which lazily import torch._dynamo to avoid circular dependencies. diff --git a/torch/_custom_op/autograd.py b/torch/_custom_op/autograd.py index 116a4612a45e..35727197d03c 100644 --- a/torch/_custom_op/autograd.py +++ b/torch/_custom_op/autograd.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch import torch.utils._pytree as pytree from collections import namedtuple diff --git a/torch/_custom_op/functional.py b/torch/_custom_op/functional.py index 26ef5b307bd5..57ff351e2e2d 100644 --- a/torch/_custom_op/functional.py +++ b/torch/_custom_op/functional.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import weakref import torch diff --git a/torch/_custom_op/impl.py b/torch/_custom_op/impl.py index d9200160057c..2f3efce60a81 100644 --- a/torch/_custom_op/impl.py +++ b/torch/_custom_op/impl.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import dataclasses import functools import inspect diff --git a/torch/_custom_ops.py b/torch/_custom_ops.py index c09a8ae68543..b8231a186c0a 100644 --- a/torch/_custom_ops.py +++ b/torch/_custom_ops.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import inspect from torch._custom_op.impl import ( diff --git a/torch/_decomp/__init__.py b/torch/_decomp/__init__.py index b277bb7eceb0..e0c7e5b6f49d 100644 --- a/torch/_decomp/__init__.py +++ b/torch/_decomp/__init__.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import inspect from collections import defaultdict from functools import wraps diff --git a/torch/_decomp/decompositions.py b/torch/_decomp/decompositions.py index 76599d299b29..7c9d342ea0f0 100644 --- a/torch/_decomp/decompositions.py +++ b/torch/_decomp/decompositions.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import functools import numbers import operator diff --git a/torch/_decomp/decompositions_for_jvp.py b/torch/_decomp/decompositions_for_jvp.py index d430386ff360..ce47ac43d372 100644 --- a/torch/_decomp/decompositions_for_jvp.py +++ b/torch/_decomp/decompositions_for_jvp.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import inspect from typing import Callable, Dict, List, Optional, Tuple diff --git a/torch/_decomp/decompositions_for_rng.py b/torch/_decomp/decompositions_for_rng.py index 1aa762351171..74eb9b9240ae 100644 --- a/torch/_decomp/decompositions_for_rng.py +++ b/torch/_decomp/decompositions_for_rng.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import functools from collections import defaultdict from typing import Callable, Dict diff --git a/torch/_deploy.py b/torch/_deploy.py index 35e8d4976940..3f8adc420672 100644 --- a/torch/_deploy.py +++ b/torch/_deploy.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import io import torch diff --git a/torch/_dispatch/python.py b/torch/_dispatch/python.py index d80839dc7e47..1d36623ba861 100644 --- a/torch/_dispatch/python.py +++ b/torch/_dispatch/python.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import itertools import unittest.mock from contextlib import contextmanager diff --git a/torch/_dynamo/_trace_wrapped_higher_order_op.py b/torch/_dynamo/_trace_wrapped_higher_order_op.py index 6e22cafcc6dd..30e44b000fd5 100644 --- a/torch/_dynamo/_trace_wrapped_higher_order_op.py +++ b/torch/_dynamo/_trace_wrapped_higher_order_op.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._C import DispatchKey from torch._higher_order_ops.utils import autograd_not_implemented diff --git a/torch/_dynamo/bytecode_analysis.py b/torch/_dynamo/bytecode_analysis.py index 340378e7266b..541c3e0cc882 100644 --- a/torch/_dynamo/bytecode_analysis.py +++ b/torch/_dynamo/bytecode_analysis.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import bisect import dataclasses import dis diff --git a/torch/_dynamo/bytecode_transformation.py b/torch/_dynamo/bytecode_transformation.py index f07fe1c7a0e0..63dbdf048f6c 100644 --- a/torch/_dynamo/bytecode_transformation.py +++ b/torch/_dynamo/bytecode_transformation.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import copy import dataclasses import dis diff --git a/torch/_dynamo/cache_size.py b/torch/_dynamo/cache_size.py index 340f227a9956..ea5e2ae0ce10 100644 --- a/torch/_dynamo/cache_size.py +++ b/torch/_dynamo/cache_size.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import logging import types import weakref diff --git a/torch/_dynamo/callback.py b/torch/_dynamo/callback.py index a65e2844f215..35f447a80349 100644 --- a/torch/_dynamo/callback.py +++ b/torch/_dynamo/callback.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs class CompilationCallbackHandler: def __init__(self): self.start_callbacks = [] diff --git a/torch/_dynamo/code_context.py b/torch/_dynamo/code_context.py index 0fe19016ca13..59c912bd30f7 100644 --- a/torch/_dynamo/code_context.py +++ b/torch/_dynamo/code_context.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import types from .utils import ExactWeakKeyDictionary diff --git a/torch/_dynamo/codegen.py b/torch/_dynamo/codegen.py index 6dbd7f36b0b5..ac0d06d9f428 100644 --- a/torch/_dynamo/codegen.py +++ b/torch/_dynamo/codegen.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import collections import dataclasses import re diff --git a/torch/_dynamo/compiled_autograd.py b/torch/_dynamo/compiled_autograd.py index bbc8d722b7e2..f13b53e7ed5f 100644 --- a/torch/_dynamo/compiled_autograd.py +++ b/torch/_dynamo/compiled_autograd.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import contextlib import functools from typing import Dict, List, Optional, TYPE_CHECKING diff --git a/torch/_dynamo/comptime.py b/torch/_dynamo/comptime.py index 80880588b54e..ffb9fbc47cca 100644 --- a/torch/_dynamo/comptime.py +++ b/torch/_dynamo/comptime.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # This file establishes the public comptime interface to Dynamo. # This allows Dynamo users to execute arbitrary Python code while # Dynamo is symbolically evaluating their original programs. diff --git a/torch/_dynamo/config.py b/torch/_dynamo/config.py index 6487a2726381..bf3d35c334aa 100644 --- a/torch/_dynamo/config.py +++ b/torch/_dynamo/config.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import getpass import inspect import os diff --git a/torch/_dynamo/convert_frame.py b/torch/_dynamo/convert_frame.py index 88fb2a85bca2..a1d7e7e6e130 100644 --- a/torch/_dynamo/convert_frame.py +++ b/torch/_dynamo/convert_frame.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import collections import cProfile import dis diff --git a/torch/_dynamo/create_parameter_op.py b/torch/_dynamo/create_parameter_op.py index 42981fcf1015..f6cd12de2021 100644 --- a/torch/_dynamo/create_parameter_op.py +++ b/torch/_dynamo/create_parameter_op.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch doc = """ diff --git a/torch/_dynamo/current_scope_id.py b/torch/_dynamo/current_scope_id.py index 1289bdcdffe4..ad079875b58a 100644 --- a/torch/_dynamo/current_scope_id.py +++ b/torch/_dynamo/current_scope_id.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import contextlib import threading diff --git a/torch/_dynamo/debug_utils.py b/torch/_dynamo/debug_utils.py index 4b4b37a34da9..e262f8cbdb71 100644 --- a/torch/_dynamo/debug_utils.py +++ b/torch/_dynamo/debug_utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # mypy: disable-error-code="method-assign" import copy diff --git a/torch/_dynamo/decorators.py b/torch/_dynamo/decorators.py index 01c629709bd8..557b9a72dde1 100644 --- a/torch/_dynamo/decorators.py +++ b/torch/_dynamo/decorators.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # ruff: noqa: TCH004 from dataclasses import dataclass from typing import TYPE_CHECKING diff --git a/torch/_dynamo/device_interface.py b/torch/_dynamo/device_interface.py index d93a26546683..aa8848014b34 100644 --- a/torch/_dynamo/device_interface.py +++ b/torch/_dynamo/device_interface.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import inspect from typing import Any, Callable, Dict, Iterable, Optional, Tuple, Type, Union diff --git a/torch/_dynamo/eval_frame.py b/torch/_dynamo/eval_frame.py index 94cad71f7ef5..2fc451cf3d17 100644 --- a/torch/_dynamo/eval_frame.py +++ b/torch/_dynamo/eval_frame.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # mypy: disable-error-code="method-assign" """ diff --git a/torch/_dynamo/exc.py b/torch/_dynamo/exc.py index d9f4c847d030..f3cc073b8a30 100644 --- a/torch/_dynamo/exc.py +++ b/torch/_dynamo/exc.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os import textwrap from enum import auto, Enum diff --git a/torch/_dynamo/external_utils.py b/torch/_dynamo/external_utils.py index 1aea186bb679..7982e77f6feb 100644 --- a/torch/_dynamo/external_utils.py +++ b/torch/_dynamo/external_utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # This module contains functions that *will be allowed* by dynamo import functools diff --git a/torch/_dynamo/guards.py b/torch/_dynamo/guards.py index ac46b4df0f38..fc3f12847a75 100644 --- a/torch/_dynamo/guards.py +++ b/torch/_dynamo/guards.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import ast diff --git a/torch/_dynamo/logging.py b/torch/_dynamo/logging.py index 1e9a820785be..316b3ec817cb 100644 --- a/torch/_dynamo/logging.py +++ b/torch/_dynamo/logging.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import itertools import logging diff --git a/torch/_dynamo/mutation_guard.py b/torch/_dynamo/mutation_guard.py index 1fa24cfa25bb..22e2b9999e03 100644 --- a/torch/_dynamo/mutation_guard.py +++ b/torch/_dynamo/mutation_guard.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # mypy: disable-error-code="method-assign" import functools diff --git a/torch/_dynamo/output_graph.py b/torch/_dynamo/output_graph.py index 03e7f844cbd4..ee43db8524a7 100644 --- a/torch/_dynamo/output_graph.py +++ b/torch/_dynamo/output_graph.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import collections import contextlib import copy diff --git a/torch/_dynamo/profiler.py b/torch/_dynamo/profiler.py index b52551c67137..b7e9553ce219 100644 --- a/torch/_dynamo/profiler.py +++ b/torch/_dynamo/profiler.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import dataclasses import os from typing import Any, List diff --git a/torch/_dynamo/replay_record.py b/torch/_dynamo/replay_record.py index 7a312e5d58a9..0049dfe7d3ef 100644 --- a/torch/_dynamo/replay_record.py +++ b/torch/_dynamo/replay_record.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import dataclasses from dataclasses import field from types import CodeType, ModuleType diff --git a/torch/_dynamo/repro/after_aot.py b/torch/_dynamo/repro/after_aot.py index 0dbf3cd5c0e4..98149c72c02c 100644 --- a/torch/_dynamo/repro/after_aot.py +++ b/torch/_dynamo/repro/after_aot.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import argparse import copy import functools diff --git a/torch/_dynamo/repro/after_dynamo.py b/torch/_dynamo/repro/after_dynamo.py index 43f761f84d3d..254f293951ee 100644 --- a/torch/_dynamo/repro/after_dynamo.py +++ b/torch/_dynamo/repro/after_dynamo.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import argparse import copy import functools diff --git a/torch/_dynamo/resume_execution.py b/torch/_dynamo/resume_execution.py index 387adc06272a..3dae1b3b9b10 100644 --- a/torch/_dynamo/resume_execution.py +++ b/torch/_dynamo/resume_execution.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import copy import dataclasses import sys diff --git a/torch/_dynamo/side_effects.py b/torch/_dynamo/side_effects.py index 647fae379c54..229282f709cb 100644 --- a/torch/_dynamo/side_effects.py +++ b/torch/_dynamo/side_effects.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import inspect import warnings from typing import Any, Dict, List, Optional, Union diff --git a/torch/_dynamo/source.py b/torch/_dynamo/source.py index ded62ba97d8a..69423712c53c 100644 --- a/torch/_dynamo/source.py +++ b/torch/_dynamo/source.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import collections import dataclasses import enum diff --git a/torch/_dynamo/symbolic_convert.py b/torch/_dynamo/symbolic_convert.py index 71ed48fbb292..41ceaa615916 100644 --- a/torch/_dynamo/symbolic_convert.py +++ b/torch/_dynamo/symbolic_convert.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import collections import collections.abc import contextlib diff --git a/torch/_dynamo/tensor_version_op.py b/torch/_dynamo/tensor_version_op.py index 4c4246474c1d..290f03ad0c6e 100644 --- a/torch/_dynamo/tensor_version_op.py +++ b/torch/_dynamo/tensor_version_op.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._prims import _make_prim, RETURN_TYPE from torch._subclasses import FakeTensorMode diff --git a/torch/_dynamo/test_case.py b/torch/_dynamo/test_case.py index 297ea6e2bc2a..0489b6acc963 100644 --- a/torch/_dynamo/test_case.py +++ b/torch/_dynamo/test_case.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import contextlib import importlib import logging diff --git a/torch/_dynamo/test_minifier_common.py b/torch/_dynamo/test_minifier_common.py index d12e5a92315a..4736c75785cc 100644 --- a/torch/_dynamo/test_minifier_common.py +++ b/torch/_dynamo/test_minifier_common.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import dataclasses import io import logging diff --git a/torch/_dynamo/testing.py b/torch/_dynamo/testing.py index 99b6607afead..527e0138fc25 100644 --- a/torch/_dynamo/testing.py +++ b/torch/_dynamo/testing.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import contextlib import dis import functools diff --git a/torch/_dynamo/trace_rules.py b/torch/_dynamo/trace_rules.py index 4f2bee755ae7..585ddb04eda1 100644 --- a/torch/_dynamo/trace_rules.py +++ b/torch/_dynamo/trace_rules.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import _collections_abc import _weakrefset import abc diff --git a/torch/_dynamo/utils.py b/torch/_dynamo/utils.py index 60be7898d929..6da8b514f16b 100644 --- a/torch/_dynamo/utils.py +++ b/torch/_dynamo/utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import atexit import collections import contextlib diff --git a/torch/_dynamo/variables/script_object.py b/torch/_dynamo/variables/script_object.py index 70354e28bb3d..923437193640 100644 --- a/torch/_dynamo/variables/script_object.py +++ b/torch/_dynamo/variables/script_object.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import functools from typing import Dict diff --git a/torch/_dynamo/variables/torch.py b/torch/_dynamo/variables/torch.py index 0b3e28860aaf..4d7b96b6a320 100644 --- a/torch/_dynamo/variables/torch.py +++ b/torch/_dynamo/variables/torch.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import functools import inspect import logging diff --git a/torch/_export/__init__.py b/torch/_export/__init__.py index d41ff4b53af0..d9a514232569 100644 --- a/torch/_export/__init__.py +++ b/torch/_export/__init__.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import copy import dataclasses import functools diff --git a/torch/_export/converter.py b/torch/_export/converter.py index 777249c24a2a..20b6101948de 100644 --- a/torch/_export/converter.py +++ b/torch/_export/converter.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import operator from typing import Any, Dict, List, Optional, Set, Tuple, Union diff --git a/torch/_export/db/case.py b/torch/_export/db/case.py index 6c4c03572e3a..21b456fbe029 100644 --- a/torch/_export/db/case.py +++ b/torch/_export/db/case.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import inspect import re import string diff --git a/torch/_export/db/examples/__init__.py b/torch/_export/db/examples/__init__.py index d737548c3d48..2e93d4b80824 100644 --- a/torch/_export/db/examples/__init__.py +++ b/torch/_export/db/examples/__init__.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import glob import importlib from os.path import basename, dirname, isfile, join diff --git a/torch/_export/db/examples/assume_constant_result.py b/torch/_export/db/examples/assume_constant_result.py index 0078200bc0f0..1503e0c91134 100644 --- a/torch/_export/db/examples/assume_constant_result.py +++ b/torch/_export/db/examples/assume_constant_result.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch import torch._dynamo as torchdynamo diff --git a/torch/_export/db/examples/autograd_function.py b/torch/_export/db/examples/autograd_function.py index 9c8aeadc45ae..3c9099b0cdb8 100644 --- a/torch/_export/db/examples/autograd_function.py +++ b/torch/_export/db/examples/autograd_function.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/class_method.py b/torch/_export/db/examples/class_method.py index 838a0a1cdb67..831339372274 100644 --- a/torch/_export/db/examples/class_method.py +++ b/torch/_export/db/examples/class_method.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/cond_branch_class_method.py b/torch/_export/db/examples/cond_branch_class_method.py index 40430d23c0f2..21fe1d25516a 100644 --- a/torch/_export/db/examples/cond_branch_class_method.py +++ b/torch/_export/db/examples/cond_branch_class_method.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/cond_branch_nested_function.py b/torch/_export/db/examples/cond_branch_nested_function.py index 00bce0b580a1..03639c0a207d 100644 --- a/torch/_export/db/examples/cond_branch_nested_function.py +++ b/torch/_export/db/examples/cond_branch_nested_function.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/cond_branch_nonlocal_variables.py b/torch/_export/db/examples/cond_branch_nonlocal_variables.py index 2db6192117df..676e7d21ffd2 100644 --- a/torch/_export/db/examples/cond_branch_nonlocal_variables.py +++ b/torch/_export/db/examples/cond_branch_nonlocal_variables.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/cond_closed_over_variable.py b/torch/_export/db/examples/cond_closed_over_variable.py index 226576cc83f7..cf4787f481c4 100644 --- a/torch/_export/db/examples/cond_closed_over_variable.py +++ b/torch/_export/db/examples/cond_closed_over_variable.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/cond_operands.py b/torch/_export/db/examples/cond_operands.py index 1a0db6a110d3..03fd467959a2 100644 --- a/torch/_export/db/examples/cond_operands.py +++ b/torch/_export/db/examples/cond_operands.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/cond_predicate.py b/torch/_export/db/examples/cond_predicate.py index c72c11e32f57..fa3cdeaf3b05 100644 --- a/torch/_export/db/examples/cond_predicate.py +++ b/torch/_export/db/examples/cond_predicate.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/constrain_as_size_example.py b/torch/_export/db/examples/constrain_as_size_example.py index 16d646252414..a3664b7e80f1 100644 --- a/torch/_export/db/examples/constrain_as_size_example.py +++ b/torch/_export/db/examples/constrain_as_size_example.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/constrain_as_value_example.py b/torch/_export/db/examples/constrain_as_value_example.py index 1de266c689c4..b1b412d41391 100644 --- a/torch/_export/db/examples/constrain_as_value_example.py +++ b/torch/_export/db/examples/constrain_as_value_example.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/decorator.py b/torch/_export/db/examples/decorator.py index fbc95182e60e..da963ce7da01 100644 --- a/torch/_export/db/examples/decorator.py +++ b/torch/_export/db/examples/decorator.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import functools import torch diff --git a/torch/_export/db/examples/dictionary.py b/torch/_export/db/examples/dictionary.py index 5a210906e680..19f138e6f4d1 100644 --- a/torch/_export/db/examples/dictionary.py +++ b/torch/_export/db/examples/dictionary.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/dynamic_shape_assert.py b/torch/_export/db/examples/dynamic_shape_assert.py index 52cc43a21049..57ba98552e0c 100644 --- a/torch/_export/db/examples/dynamic_shape_assert.py +++ b/torch/_export/db/examples/dynamic_shape_assert.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/dynamic_shape_constructor.py b/torch/_export/db/examples/dynamic_shape_constructor.py index 599747f7968a..5ce7fdda2877 100644 --- a/torch/_export/db/examples/dynamic_shape_constructor.py +++ b/torch/_export/db/examples/dynamic_shape_constructor.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/dynamic_shape_if_guard.py b/torch/_export/db/examples/dynamic_shape_if_guard.py index 2120ec0145fe..9350c6d992f5 100644 --- a/torch/_export/db/examples/dynamic_shape_if_guard.py +++ b/torch/_export/db/examples/dynamic_shape_if_guard.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/dynamic_shape_map.py b/torch/_export/db/examples/dynamic_shape_map.py index 5607c2796d68..421d4b355efb 100644 --- a/torch/_export/db/examples/dynamic_shape_map.py +++ b/torch/_export/db/examples/dynamic_shape_map.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/dynamic_shape_round.py b/torch/_export/db/examples/dynamic_shape_round.py index d581d6d839bc..57a1e07dab97 100644 --- a/torch/_export/db/examples/dynamic_shape_round.py +++ b/torch/_export/db/examples/dynamic_shape_round.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case, SupportLevel diff --git a/torch/_export/db/examples/dynamic_shape_slicing.py b/torch/_export/db/examples/dynamic_shape_slicing.py index eb237876f4e6..ddc2f86f774c 100644 --- a/torch/_export/db/examples/dynamic_shape_slicing.py +++ b/torch/_export/db/examples/dynamic_shape_slicing.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/dynamic_shape_view.py b/torch/_export/db/examples/dynamic_shape_view.py index bcedd04cf36f..666da36ad2a8 100644 --- a/torch/_export/db/examples/dynamic_shape_view.py +++ b/torch/_export/db/examples/dynamic_shape_view.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/fn_with_kwargs.py b/torch/_export/db/examples/fn_with_kwargs.py index 6182a7479555..d5a9a23415d9 100644 --- a/torch/_export/db/examples/fn_with_kwargs.py +++ b/torch/_export/db/examples/fn_with_kwargs.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case, ExportArgs, SupportLevel diff --git a/torch/_export/db/examples/list_contains.py b/torch/_export/db/examples/list_contains.py index d25d815cde1a..6105220c09b9 100644 --- a/torch/_export/db/examples/list_contains.py +++ b/torch/_export/db/examples/list_contains.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/list_unpack.py b/torch/_export/db/examples/list_unpack.py index 2251c6eb360d..66b4fe456a0d 100644 --- a/torch/_export/db/examples/list_unpack.py +++ b/torch/_export/db/examples/list_unpack.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import List import torch diff --git a/torch/_export/db/examples/model_attr_mutation.py b/torch/_export/db/examples/model_attr_mutation.py index 409a0c0f6c03..4c2a03d4e77b 100644 --- a/torch/_export/db/examples/model_attr_mutation.py +++ b/torch/_export/db/examples/model_attr_mutation.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case, SupportLevel diff --git a/torch/_export/db/examples/nested_function.py b/torch/_export/db/examples/nested_function.py index 608ef39d5187..cc668ee561a6 100644 --- a/torch/_export/db/examples/nested_function.py +++ b/torch/_export/db/examples/nested_function.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/null_context_manager.py b/torch/_export/db/examples/null_context_manager.py index da759b0980fa..ff4b94e6bf44 100644 --- a/torch/_export/db/examples/null_context_manager.py +++ b/torch/_export/db/examples/null_context_manager.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import contextlib import torch diff --git a/torch/_export/db/examples/optional_input.py b/torch/_export/db/examples/optional_input.py index 47bb5e1bab8d..dfc256d6a5ce 100644 --- a/torch/_export/db/examples/optional_input.py +++ b/torch/_export/db/examples/optional_input.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case, SupportLevel diff --git a/torch/_export/db/examples/pytree_flatten.py b/torch/_export/db/examples/pytree_flatten.py index 0d799b2a609a..9c91cc21df3c 100644 --- a/torch/_export/db/examples/pytree_flatten.py +++ b/torch/_export/db/examples/pytree_flatten.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case, SupportLevel diff --git a/torch/_export/db/examples/scalar_output.py b/torch/_export/db/examples/scalar_output.py index 86217847bff8..46e03c1f7e94 100644 --- a/torch/_export/db/examples/scalar_output.py +++ b/torch/_export/db/examples/scalar_output.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/specialized_attribute.py b/torch/_export/db/examples/specialized_attribute.py index 3f8f09c4128d..a53ad213c63f 100644 --- a/torch/_export/db/examples/specialized_attribute.py +++ b/torch/_export/db/examples/specialized_attribute.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from enum import Enum import torch diff --git a/torch/_export/db/examples/static_for_loop.py b/torch/_export/db/examples/static_for_loop.py index af14f6fe8ae1..4ad60737ff5d 100644 --- a/torch/_export/db/examples/static_for_loop.py +++ b/torch/_export/db/examples/static_for_loop.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/static_if.py b/torch/_export/db/examples/static_if.py index 048bf20ce8bf..bc5dce9f0667 100644 --- a/torch/_export/db/examples/static_if.py +++ b/torch/_export/db/examples/static_if.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case diff --git a/torch/_export/db/examples/tensor_setattr.py b/torch/_export/db/examples/tensor_setattr.py index fae18fb1cf93..201dca37c81a 100644 --- a/torch/_export/db/examples/tensor_setattr.py +++ b/torch/_export/db/examples/tensor_setattr.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case, SupportLevel diff --git a/torch/_export/db/examples/torch_sym_min.py b/torch/_export/db/examples/torch_sym_min.py index f7edc7003f14..a8fe560773a4 100644 --- a/torch/_export/db/examples/torch_sym_min.py +++ b/torch/_export/db/examples/torch_sym_min.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case, SupportLevel diff --git a/torch/_export/db/examples/type_reflection_method.py b/torch/_export/db/examples/type_reflection_method.py index 869fb4cadd65..5d6570ca0cb9 100644 --- a/torch/_export/db/examples/type_reflection_method.py +++ b/torch/_export/db/examples/type_reflection_method.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case, SupportLevel, export_rewrite_case diff --git a/torch/_export/db/examples/user_input_mutation.py b/torch/_export/db/examples/user_input_mutation.py index 01c5d775a264..b60036257617 100644 --- a/torch/_export/db/examples/user_input_mutation.py +++ b/torch/_export/db/examples/user_input_mutation.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch._export.db.case import export_case, SupportLevel diff --git a/torch/_export/db/logging.py b/torch/_export/db/logging.py index fc412b8c5082..8cd0827d3893 100644 --- a/torch/_export/db/logging.py +++ b/torch/_export/db/logging.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def exportdb_error_message(case_name: str): return "" diff --git a/torch/_export/exported_program.py b/torch/_export/exported_program.py index 5d28ea315490..49dfd0cf996e 100644 --- a/torch/_export/exported_program.py +++ b/torch/_export/exported_program.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import warnings diff --git a/torch/_export/non_strict_utils.py b/torch/_export/non_strict_utils.py index d15cb29f28df..9db3653de1e2 100644 --- a/torch/_export/non_strict_utils.py +++ b/torch/_export/non_strict_utils.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import contextlib import inspect from collections import defaultdict diff --git a/torch/_export/pass_base.py b/torch/_export/pass_base.py index 1cf7e75ad5f9..2200193e78a5 100644 --- a/torch/_export/pass_base.py +++ b/torch/_export/pass_base.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import operator import traceback import typing diff --git a/torch/_export/pass_infra/proxy_value.py b/torch/_export/pass_infra/proxy_value.py index 66592d48a45e..07d888b30656 100644 --- a/torch/_export/pass_infra/proxy_value.py +++ b/torch/_export/pass_infra/proxy_value.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # pyre-strict from typing import Union diff --git a/torch/_export/passes/_node_metadata_hook.py b/torch/_export/passes/_node_metadata_hook.py index e04059a9114a..3dd87b546da8 100644 --- a/torch/_export/passes/_node_metadata_hook.py +++ b/torch/_export/passes/_node_metadata_hook.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import contextlib import torch diff --git a/torch/_export/passes/add_runtime_assertions_for_constraints_pass.py b/torch/_export/passes/add_runtime_assertions_for_constraints_pass.py index 5a2a8b5874bf..44f0ea270212 100644 --- a/torch/_export/passes/add_runtime_assertions_for_constraints_pass.py +++ b/torch/_export/passes/add_runtime_assertions_for_constraints_pass.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import math import operator import traceback diff --git a/torch/_export/passes/collect_tracepoints_pass.py b/torch/_export/passes/collect_tracepoints_pass.py index ca8eaf30be59..8d65a720b9d7 100644 --- a/torch/_export/passes/collect_tracepoints_pass.py +++ b/torch/_export/passes/collect_tracepoints_pass.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import operator import torch diff --git a/torch/_export/passes/lift_constants_pass.py b/torch/_export/passes/lift_constants_pass.py index 83914fb828c5..d9cd62ffc928 100644 --- a/torch/_export/passes/lift_constants_pass.py +++ b/torch/_export/passes/lift_constants_pass.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import collections from typing import Any, Dict, List, Union diff --git a/torch/_export/passes/remove_runtime_assertions.py b/torch/_export/passes/remove_runtime_assertions.py index adcc708e5548..a80b62d2765a 100644 --- a/torch/_export/passes/remove_runtime_assertions.py +++ b/torch/_export/passes/remove_runtime_assertions.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import torch from torch.fx.passes.infra.pass_base import PassBase, PassResult diff --git a/torch/_export/passes/replace_set_grad_with_hop_pass.py b/torch/_export/passes/replace_set_grad_with_hop_pass.py index 91104c17c38d..0b0bef582e45 100644 --- a/torch/_export/passes/replace_set_grad_with_hop_pass.py +++ b/torch/_export/passes/replace_set_grad_with_hop_pass.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import contextlib import copy diff --git a/torch/_export/passes/replace_sym_size_ops_pass.py b/torch/_export/passes/replace_sym_size_ops_pass.py index 109a96d7b4bd..29d594d41f06 100644 --- a/torch/_export/passes/replace_sym_size_ops_pass.py +++ b/torch/_export/passes/replace_sym_size_ops_pass.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import Dict import torch diff --git a/torch/_export/passes/replace_view_ops_with_view_copy_ops_pass.py b/torch/_export/passes/replace_view_ops_with_view_copy_ops_pass.py index f32b442733eb..edc249b572b5 100644 --- a/torch/_export/passes/replace_view_ops_with_view_copy_ops_pass.py +++ b/torch/_export/passes/replace_view_ops_with_view_copy_ops_pass.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import Dict, Optional, Set import torch