Skip to content

Commit 8db9dfa

Browse files
aorenstepytorchmergebot
authored andcommitted
Flip default value for mypy disallow_untyped_defs [9/11] (pytorch#127846)
See pytorch#127836 for details. Pull Request resolved: pytorch#127846 Approved by: https://github.com/ezyang ghstack dependencies: pytorch#127842, pytorch#127843, pytorch#127844, pytorch#127845
1 parent 27f9d3b commit 8db9dfa

File tree

128 files changed

+129
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+129
-1
lines changed

torch/package/_package_pickler.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""isort:skip_file"""
23
from pickle import ( # type: ignore[attr-defined]
34
_compat_pickle,

torch/package/_package_unpickler.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import _compat_pickle
23
import pickle
34

torch/package/_stdlib.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""List of Python standard library modules.
23
34
Sadly, there is no reliable way to tell whether a module is part of the

torch/package/analyze/trace_dependencies.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import sys
23
from typing import Any, Callable, Iterable, List, Tuple
34

torch/package/file_structure_representation.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
from typing import Dict, List
23

34
from .glob_group import GlobGroup, GlobPattern

torch/package/find_file_dependencies.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import ast
23
from typing import List, Optional, Tuple
34

torch/package/glob_group.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import re
23
from typing import Iterable, Union
34

torch/package/importer.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import importlib
23
from abc import ABC, abstractmethod
34
from pickle import ( # type: ignore[attr-defined] # type: ignore[attr-defined]

torch/package/package_exporter.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import collections
23
import importlib.machinery
34
import io

torch/package/package_importer.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import builtins
23
import importlib
34
import importlib.machinery

torch/profiler/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
r"""
23
PyTorch Profiler is a tool that allows the collection of performance metrics during training and inference.
34
Profiler's context manager API can be used to better understand what model operators are the most expensive,

torch/profiler/_memory_profiler.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import collections
23
import dataclasses
34
import enum

torch/profiler/_pattern_matcher.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import json
23
import math
34
import os

torch/profiler/_utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import functools
23
import operator
34
import re

torch/profiler/itt.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
from contextlib import contextmanager
23

34
try:

torch/profiler/profiler.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import gzip
23
import json
34
import os

torch/quantization/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
from .quantize import * # noqa: F403
23
from .observer import * # noqa: F403
34
from .qconfig import * # noqa: F403

torch/quantization/_quantized_conversions.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import torch
23

34

torch/quasirandom.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import torch
23
from typing import Optional
34

torch/random.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import contextlib
23
from typing import Generator
34
import warnings

torch/serialization.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import difflib
23
import functools
34
import os

torch/signal/windows/windows.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
from typing import Optional, Iterable
23

34
import torch

torch/sparse/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
# The Tensor classes are added to this module by python_tensor.cpp
23
from typing import Optional, Tuple, List, Union, Any
34

torch/sparse/_semi_structured_conversions.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import torch
23

34

torch/sparse/_semi_structured_ops.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import contextlib
23

34
import torch

torch/sparse/_triton_ops.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import math
23
import os
34
import torch

torch/sparse/_triton_ops_meta.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Provides optimal triton kernel parameters.
23
34
Aim

torch/sparse/semi_structured.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import warnings
23
from collections import namedtuple
34
from typing import Any, Optional, Tuple, List, Callable, Dict

torch/storage.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import io
23

34
import torch

torch/testing/_comparison.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import abc
23
import cmath
34
import collections.abc

torch/testing/_internal/common_fsdp.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
# Owner(s): ["oncall: distributed"]
23

34
import contextlib

torch/testing/_internal/custom_op_db.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import torch
23
import functools
34
from torch.testing import make_tensor

torch/testing/_internal/dynamo_test_failures.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import logging
23
import os
34
import sys

torch/testing/_internal/static_module.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
# Owner(s): ["module: unknown"]
23

34
import torch

torch/testing/_internal/torchbind_impls.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import contextlib
23
from typing import Optional
34

torch/testing/_utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import contextlib
23

34
import torch

torch/types.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import builtins
23
from typing import Any, List, Optional, Sequence, Tuple, Union
34

torch/utils/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import os.path as _osp
23
import torch
34

torch/utils/_config_module.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import contextlib
23

34
import copy

torch/utils/_config_typing.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
from typing import Any, Dict, Optional, TYPE_CHECKING, Union
23

34
"""

torch/utils/_content_store.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
# This module provides a FAST (on GPU) content addressable store for storages
23
# (and tensors on top of them) with VERY WEAK portability guarantees (e.g.,
34
# don't expect CPU/CUDA to address to the same hash, don't expect it to be

torch/utils/_contextlib.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
# Extra utilities for working with context managers that should have been
23
# in the standard library but are not
34

torch/utils/_cpp_extension_versioner.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import collections
23

34

torch/utils/_device.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
from typing import Optional
23
import torch
34
from torch.overrides import TorchFunctionMode

torch/utils/_exposed_in.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
# Allows one to expose an API in a private submodule publicly as per the definition
23
# in PyTorch's public api policy.
34
#

torch/utils/_freeze.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""
23
Freeze Python packages.
34

torch/utils/_get_clean_triton.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import argparse
23
import os
34
import re

torch/utils/_import_utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import functools
23
import importlib.util
34

torch/utils/_mode_utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import torch
23
from typing import TypeVar
34

torch/utils/_python_dispatch.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import contextlib
23

34
import warnings

torch/utils/_stats.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
# NOTE! PLEASE KEEP THIS FILE *FREE* OF TORCH DEPS! IT SHOULD BE IMPORTABLE ANYWHERE.
23
# IF YOU FEEL AN OVERWHELMING URGE TO ADD A TORCH DEP, MAKE A TRAMPOLINE FILE A LA torch._dynamo.utils
34
# AND SCRUB AWAY TORCH NOTIONS THERE.

torch/utils/_strobelight/examples/cli_function_profiler_example.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import torch
23

34
from torch.utils._strobelight.cli_function_profiler import (

torch/utils/_sympy/functions.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import math
23

34
import sympy

torch/utils/_sympy/interp.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""
23
This is a simple interpreter for Sympy expressions that dispatches to
34
classes following the torch._inductor.virtualized calling convention.

torch/utils/_sympy/reference.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import math
23

34
import sympy

torch/utils/_sympy/singleton_int.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import sympy
23
from sympy.multipledispatch import dispatch
34

torch/utils/_sympy/symbol.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""
23
This file contains canonical definitions for our symbol naming conventions,
34
across torch.fx.experimental.symbolic_shapes and torch._inductor. The

torch/utils/_sympy/value_ranges.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
from __future__ import annotations
23

34
import dataclasses
@@ -586,7 +587,7 @@ def reciprocal(x):
586587
if 0 in x:
587588
return ValueRanges.unknown()
588589
else:
589-
return ValueRanges.decreasing_map(x, lambda y: 1 / y)
590+
return ValueRanges.decreasing_map(x, lambda y: 1 / y) # type: ignore[operator]
590591

591592
@staticmethod
592593
def abs(x):

torch/utils/_traceback.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
from types import TracebackType
23
from typing import List, Optional
34
import tempfile

torch/utils/_triton.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import functools
23
import hashlib
34

torch/utils/_zip.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import argparse
23
import glob
34
import os

torch/utils/backcompat/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
from torch._C import _set_backcompat_broadcast_warn
23
from torch._C import _get_backcompat_broadcast_warn
34
from torch._C import _set_backcompat_keepdim_warn

torch/utils/backend_registration.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import torch
23
from torch.overrides import (
34
handle_torch_function,

torch/utils/benchmark/examples/blas_compare_setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import collections
23
import os
34
import shutil

torch/utils/benchmark/examples/compare.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Example of Timer and Compare APIs:
23

34
$ python -m examples.compare

torch/utils/benchmark/examples/fuzzer.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Example of the Timer and Fuzzer APIs:
23

34
$ python -m examples.fuzzer

torch/utils/benchmark/examples/op_benchmark.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Example use of Timer and op fuzzers to measure kernel performance.
23

34
$ python -m examples.op_benchmark

torch/utils/benchmark/examples/simple_timeit.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Trivial use of Timer API:
23

34
$ python -m examples.simple_timeit

torch/utils/benchmark/examples/sparse/compare.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Example of Timer and Compare APIs:
23

34
$ python -m examples.sparse.compare

torch/utils/benchmark/examples/sparse/fuzzer.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Example of the Timer and Sparse Fuzzer APIs:
23

34
$ python -m examples.sparse.fuzzer

torch/utils/benchmark/examples/sparse/op_benchmark.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Example use of Timer and sparse op fuzzers to measure kernel performance.
23

34
$ python -m examples.sparse.op_benchmark

torch/utils/benchmark/examples/spectral_ops_fuzz_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Microbenchmarks for the torch.fft module"""
23
from argparse import ArgumentParser
34
from collections import namedtuple

torch/utils/benchmark/op_fuzzers/binary.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import numpy as np
23
import torch
34

torch/utils/benchmark/op_fuzzers/sparse_binary.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import numpy as np
23
import torch
34

torch/utils/benchmark/op_fuzzers/sparse_unary.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12

23
import numpy as np
34
import torch

torch/utils/benchmark/op_fuzzers/spectral.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import math
23

34
import torch

torch/utils/benchmark/op_fuzzers/unary.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import numpy as np
23
import torch
34

torch/utils/benchmark/utils/compare.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Display class to aggregate and print the results of many measurements."""
23
import collections
34
import enum

0 commit comments

Comments
 (0)