pytorch/torch
Edward Z. Yang 4f13f69a45 Enable possibly-undefined error code (#118533)
Fixes https://github.com/pytorch/pytorch/issues/118129

Suppressions automatically added with

```
import re

with open("error_file.txt", "r") as f:
    errors = f.readlines()

error_lines = {}
for error in errors:
    match = re.match(r"(.*):(\d+):\d+: error:.*\[(.*)\]", error)
    if match:
        file_path, line_number, error_type = match.groups()
        if file_path not in error_lines:
            error_lines[file_path] = {}
        error_lines[file_path][int(line_number)] = error_type

for file_path, lines in error_lines.items():
    with open(file_path, "r") as f:
        code = f.readlines()
    for line_number, error_type in sorted(lines.items(), key=lambda x: x[0], reverse=True):
        code[line_number - 1] = code[line_number - 1].rstrip() + f"  # type: ignore[{error_type}]\n"
    with open(file_path, "w") as f:
        f.writelines(code)
```

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: https://github.com/pytorch/pytorch/pull/118533
Approved by: https://github.com/Skylion007, https://github.com/zou3519
2024-01-30 05:08:10 +00:00
..
_awaits
_C Allow using native c10d_functional via _functional_collectives (#113057) 2024-01-30 02:34:25 +00:00
_C_flatbuffer
_custom_op
_decomp Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
_dispatch
_dynamo Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
_export [export] Remove the branch for skipping verifier. (#118139) 2024-01-30 02:58:03 +00:00
_functorch Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
_higher_order_ops Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
_inductor Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
_lazy
_library
_logging
_numpy Handle some numpy functions with out arguments correctly in dynamo (#118248) 2024-01-29 09:09:21 +00:00
_prims Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
_prims_common Don't check is_conj for _refs.linalg.svd (#117972) 2024-01-26 15:24:29 +00:00
_refs Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
_subclasses Replace follow_imports = silent with normal (#118414) 2024-01-27 02:44:11 +00:00
_vendor
amp add GradScaler on CPU (#109993) 2024-01-29 23:42:35 +00:00
ao Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
autograd Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
backends Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
compiler
contrib
cpu add GradScaler on CPU (#109993) 2024-01-29 23:42:35 +00:00
csrc Allow using native c10d_functional via _functional_collectives (#113057) 2024-01-30 02:34:25 +00:00
cuda Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
distributed Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
distributions Enable local_partial_types (#118467) 2024-01-28 13:38:22 +00:00
export Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
fft
func
futures
fx Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
jit Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
legacy
lib
linalg
masked Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
monitor
mps
multiprocessing
nested [Nested Tensor] Support ragged_idx != 1 on aten::is_same_size, aten::_to_copy (#118442) 2024-01-30 01:32:51 +00:00
nn Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
onnx Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
optim Add compilable foreach RAdam support (#117912) 2024-01-27 04:32:27 +00:00
package
profiler Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
quantization Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
signal
sparse Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
special
testing Add Support for CausalBias to torch compile (#116071) 2024-01-30 02:22:48 +00:00
utils Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
__config__.py
__future__.py
__init__.py Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
_appdirs.py
_classes.py
_compile.py
_custom_ops.py
_deploy.py
_guards.py Enable local_partial_types (#118467) 2024-01-28 13:38:22 +00:00
_jit_internal.py Enable local_partial_types (#118467) 2024-01-28 13:38:22 +00:00
_linalg_utils.py
_lobpcg.py
_lowrank.py
_meta_registrations.py Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
_namedtensor_internals.py
_ops.py Enable local_partial_types (#118467) 2024-01-28 13:38:22 +00:00
_python_dispatcher.py
_sources.py
_storage_docs.py
_streambase.py
_tensor.py
_tensor_docs.py
_tensor_str.py Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
_torch_docs.py Clarified sampling process of torch.randn for complex dtypes. (#118315) 2024-01-26 13:05:19 +00:00
_utils.py
_utils_internal.py Revert "Add justknobs env helper for pytorch distributed (#118451)" 2024-01-29 19:01:05 +00:00
_VF.py
_vmap_internals.py
_weights_only_unpickler.py
abi-check.cpp
CMakeLists.txt
custom_class.h
custom_class_detail.h
extension.h
functional.py Fix return type hint for list types (#118238) 2024-01-25 23:35:20 +00:00
hub.py Enable possibly-undefined error code (#118533) 2024-01-30 05:08:10 +00:00
library.h Add way to actually delete a torch.library.Library object (#118318) 2024-01-26 22:30:51 +00:00
library.py Enable local_partial_types (#118467) 2024-01-28 13:38:22 +00:00
overrides.py
py.typed
quasirandom.py
random.py
README.txt
return_types.py
script.h
serialization.py Enable local_partial_types (#118467) 2024-01-28 13:38:22 +00:00
storage.py
torch_version.py Replace follow_imports = silent with normal (#118414) 2024-01-27 02:44:11 +00:00
types.py
version.py.tpl

Note [TH abstraction violation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

TH/THC provide some hpp headers, which are proper C++ headers rather than
C headers.  These headers serve double duty as *internal implementation
detail* headers, whose contents should largely not be used by external
clients.

Ideally, we would not install these headers at all; instead, you should
use public functions (in headers like `THTensor.h`, NOT `THTensor.hpp`)
to manipulate these structs.  However, there are a few places
in torch/csrc where we violate this abstraction.  They are marked with
a pointer to this note.  Each of those sites will have to be refactored
when we refactor the guts of THTensor and related structures.