Flip default value for mypy disallow_untyped_defs [9/11] (#127846)

See #127836 for details.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/127846
Approved by: https://github.com/ezyang
ghstack dependencies: #127842, #127843, #127844, #127845
This commit is contained in:
Aaron Orenstein
2024-06-08 11:41:16 -07:00
committed by PyTorch MergeBot
parent 27f9d3b0a1
commit 8db9dfa2d7
128 changed files with 129 additions and 1 deletions

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
"""isort:skip_file"""
from pickle import ( # type: ignore[attr-defined]
_compat_pickle,

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import _compat_pickle
import pickle

View File

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

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import sys
from typing import Any, Callable, Iterable, List, Tuple

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Dict, List
from .glob_group import GlobGroup, GlobPattern

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import ast
from typing import List, Optional, Tuple

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import re
from typing import Iterable, Union

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import importlib
from abc import ABC, abstractmethod
from pickle import ( # type: ignore[attr-defined] # type: ignore[attr-defined]

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import collections
import importlib.machinery
import io

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import builtins
import importlib
import importlib.machinery

View File

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

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import collections
import dataclasses
import enum

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import json
import math
import os

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import functools
import operator
import re

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from contextlib import contextmanager
try:

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import gzip
import json
import os

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from .quantize import * # noqa: F403
from .observer import * # noqa: F403
from .qconfig import * # noqa: F403

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch
from typing import Optional

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import contextlib
from typing import Generator
import warnings

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import difflib
import functools
import os

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Optional, Iterable
import torch

View File

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

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import contextlib
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import math
import os
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
"""Provides optimal triton kernel parameters.
Aim

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import warnings
from collections import namedtuple
from typing import Any, Optional, Tuple, List, Callable, Dict

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import io
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import abc
import cmath
import collections.abc

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
# Owner(s): ["oncall: distributed"]
import contextlib

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch
import functools
from torch.testing import make_tensor

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import logging
import os
import sys

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
# Owner(s): ["module: unknown"]
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import contextlib
from typing import Optional

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import contextlib
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import builtins
from typing import Any, List, Optional, Sequence, Tuple, Union

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import os.path as _osp
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import contextlib
import copy

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Any, Dict, Optional, TYPE_CHECKING, Union
"""

View File

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

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
# Extra utilities for working with context managers that should have been
# in the standard library but are not

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import collections

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Optional
import torch
from torch.overrides import TorchFunctionMode

View File

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

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
"""
Freeze Python packages.

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import argparse
import os
import re

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import functools
import importlib.util

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch
from typing import TypeVar

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import contextlib
import warnings

View File

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

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch
from torch.utils._strobelight.cli_function_profiler import (

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import math
import sympy

View File

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

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import math
import sympy

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import sympy
from sympy.multipledispatch import dispatch

View File

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

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from __future__ import annotations
import dataclasses
@ -586,7 +587,7 @@ class SymPyValueRangeAnalysis:
if 0 in x:
return ValueRanges.unknown()
else:
return ValueRanges.decreasing_map(x, lambda y: 1 / y)
return ValueRanges.decreasing_map(x, lambda y: 1 / y) # type: ignore[operator]
@staticmethod
def abs(x):

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from types import TracebackType
from typing import List, Optional
import tempfile

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import functools
import hashlib

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import argparse
import glob
import os

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from torch._C import _set_backcompat_broadcast_warn
from torch._C import _get_backcompat_broadcast_warn
from torch._C import _set_backcompat_keepdim_warn

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch
from torch.overrides import (
handle_torch_function,

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import collections
import os
import shutil

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
"""Example of Timer and Compare APIs:
$ python -m examples.compare

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
"""Example of the Timer and Fuzzer APIs:
$ python -m examples.fuzzer

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
"""Example use of Timer and op fuzzers to measure kernel performance.
$ python -m examples.op_benchmark

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
"""Trivial use of Timer API:
$ python -m examples.simple_timeit

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
"""Example of Timer and Compare APIs:
$ python -m examples.sparse.compare

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
"""Example of the Timer and Sparse Fuzzer APIs:
$ python -m examples.sparse.fuzzer

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
"""Example use of Timer and sparse op fuzzers to measure kernel performance.
$ python -m examples.sparse.op_benchmark

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
"""Microbenchmarks for the torch.fft module"""
from argparse import ArgumentParser
from collections import namedtuple

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import numpy as np
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import numpy as np
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import numpy as np
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import math
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import numpy as np
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
"""Display class to aggregate and print the results of many measurements."""
import collections
import enum

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch
__all__ = ["bench_all", "benchmark_compile"]

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import functools
import itertools as it
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Optional, Tuple, Union
from numbers import Number
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import argparse
import cProfile
import pstats

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python3
# mypy: allow-untyped-defs
from typing import Any, TypeVar, Optional, Tuple, List, NamedTuple, Union, Sequence, Dict, Callable
import textwrap
import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import contextlib
import platform
import uuid

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
# Unlike the rest of the PyTorch this file must be python2 compliant.
# This script outputs relevant system environment info

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from torch._C import _get_cpp_backtrace
def get_cpp_backtrace(frames_to_skip=0, maximum_number_of_frames=64) -> str:

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import copy
import glob
import importlib

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
r"""Utility classes & functions for data loading. Code in this folder is mostly used by ../dataloder.py.
A lot of multiprocessing is used in data loading, which only supports running

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
r"""Contains definitions of the methods used by the _BaseDataLoaderIter workers.
These methods are used to collate samples fetched from dataset into Tensor(s).

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
r"""Contains definitions of the methods used by the _BaseDataLoaderIter to fetch data from an iterable-style or map-style dataset.
This logic is shared in both single- and multi-processing data loading.

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
r"""Contains definitions of the methods used by the _BaseDataLoaderIter to put fetched tensors into pinned memory.
These **needs** to be in global scope since Py2 doesn't support serializing

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
r"""Signal handling for multiprocessing data loading.
NOTE [ Signal handling in multiprocessing data loading ]

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
r""""Contains definitions of the methods used by the _BaseDataLoaderIter workers.
These **needs** to be in global scope since Py2 doesn't support serializing

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing_extensions import deprecated as _deprecated

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
r"""Definition of the DataLoader and associated iterators that subclass _BaseDataLoaderIter.
To support these two classes, in `./_utils` we define many utility methods and

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import inspect
from functools import wraps
from typing import Any, Callable, Optional, Type, Union, get_type_hints

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import inspect
import functools
from enum import Enum

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
# Taking reference from official Python typing
# https://github.com/python/cpython/blob/master/Lib/typing.py

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Any, Optional
_pandas: Any = None

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Any, Dict, List, Optional
from torch.utils.data.datapipes._decorator import functional_datapipe

Some files were not shown because too many files have changed in this diff Show More