Repository: pytorch
Issue: Lintrunner on all files fails locally even though it passes in CI
Labels: module: lint,triaged

Running locally `lintrunner --force-color --all-files` (like is done in the CI job fails with the following:

Full env:
```bash
$ python torch/utils/collect_env.py 
Collecting environment information...
PyTorch version: 2.2.0a0+gitd1ae5ef
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Fedora release 37 (Thirty Seven) (x86_64)
GCC version: (GCC) 12.3.1 20230508 (Red Hat 12.3.1-1)
Clang version: Could not collect
CMake version: version 3.27.1
Libc version: glibc-2.36

Python version: 3.11.4+ (heads/3.11:f207b346d4, Jun 11 2023, 14:33:13) [GCC 12.3.1 20230508 (Red Hat 12.3.1-1)] (64-bit runtime)
Python platform: Linux-6.5.6-100.fc37.x86_64-x86_64-with-glibc2.36
Is CUDA available: False
CUDA runtime version: 12.2.91
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3070 Ti Laptop GPU
Nvidia driver version: 535.129.03
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: False

CPU:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      39 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             20
On-line CPU(s) list:                0-19
Vendor ID:                          GenuineIntel
Model name:                         12th Gen Intel(R) Core(TM) i7-12700H
CPU family:                         6
Model:                              154
Thread(s) per core:                 2
Core(s) per socket:                 14
Socket(s):                          1
Stepping:                           3
CPU(s) scaling MHz:                 51%
CPU max MHz:                        4700.0000
CPU min MHz:                        400.0000
BogoMIPS:                           5376.00
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 cdp_l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          544 KiB (14 instances)
L1i cache:                          704 KiB (14 instances)
L2 cache:                           11.5 MiB (8 instances)
L3 cache:                           24 MiB (1 instance)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0-19
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Enhanced / Automatic IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] flake8==6.0.0
[pip3] flake8-bugbear==23.3.23
[pip3] flake8-comprehensions==3.12.0
[pip3] flake8-executable==2.1.3
[pip3] flake8-logging-format==0.9.0
[pip3] flake8-pyi==23.3.1
[pip3] flake8-simplify==0.19.3
[pip3] mypy==1.6.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.0
[pip3] optree==0.10.0
[pip3] pytorch-sphinx-theme==0.0.24
[pip3] torch==2.2.0a0+gitd1ae5ef
[pip3] torchaudio==2.0.0a0+1717eda
[pip3] torchdata==0.6.0a0+e9ee0f5
[pip3] torchvision==0.15.0a0+7dc5e5b
[pip3] torchviz==0.0.2
[conda] Could not collect
```

<details>

<summary>Full error</summary>
```
>>> Lint for aten/src/ATen/core/IListRef_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

          4  |#include <ATen/ops/empty.h>
          5  |#endif
          6  |#include <ATen/core/IListRef.h>
    >>>   7  |#include <gtest/gtest.h>
          8  |#include <algorithm>
          9  |
         10  |using namespace c10;

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'tensors' is not initialized

         10  |using namespace c10;
         11  |
         12  |static std::vector<at::Tensor> get_tensor_vector() {
    >>>  13  |  std::vector<at::Tensor> tensors;
         14  |  const size_t SIZE = 5;
         15  |  for (size_t i = 0; i < SIZE; i++) {
         16  |    tensors.emplace_back(at::empty({0}));

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'optional_tensors' is not initialized

         19  |}
         20  |
         21  |static std::vector<optional<at::Tensor>> get_boxed_opt_tensor_vector() {
    >>>  22  |  std::vector<optional<at::Tensor>> optional_tensors;
         23  |  const size_t SIZE = 5;
         24  |  for (size_t i = 0; i < SIZE * 2; i++) {
         25  |    auto opt_tensor = (i % 2 == 0) ? optional<at::Tensor>(at::empty({0})) : nullopt;

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'optional_tensors' is not initialized

         30  |
         31  |static std::vector<at::OptionalTensorRef> get_unboxed_opt_tensor_vector() {
         32  |  static std::vector<at::Tensor> tensors;
    >>>  33  |  std::vector<at::OptionalTensorRef> optional_tensors;
         34  |  constexpr size_t SIZE = 5;
         35  |  for (size_t i = 0; i < SIZE; i++) {
         36  |    tensors.push_back(at::empty({0}));



>>> Lint for aten/src/ATen/core/List_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

           1  |#include <ATen/core/List.h>
    >>>    2  |#include <gtest/gtest.h>
           3  |
           4  |using namespace c10;
           5  |



>>> Lint for c10/benchmark/intrusive_ptr_benchmark.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'benchmark/benchmark.h' file not found

         1  |#include <c10/util/intrusive_ptr.h>
         2  |#include <c10/util/irange.h>
         3  |
    >>>  4  |#include <benchmark/benchmark.h>
         5  |#include <memory>
         6  |
         7  |using c10::intrusive_ptr;

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'var' is not initialized

        24  |};
        25  |
        26  |static void BM_IntrusivePtrCtorDtor(benchmark::State& state) {
    >>> 27  |  intrusive_ptr<Foo> var = make_intrusive<Foo>(0);
        28  |  while (state.KeepRunning()) {
        29  |    // NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
        30  |    volatile intrusive_ptr<Foo> var2 = var;

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'var2' is not initialized

        27  |  intrusive_ptr<Foo> var = make_intrusive<Foo>(0);
        28  |  while (state.KeepRunning()) {
        29  |    // NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
    >>> 30  |    volatile intrusive_ptr<Foo> var2 = var;
        31  |  }
        32  |}
        33  |BENCHMARK(BM_IntrusivePtrCtorDtor);

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'var' is not initialized

        42  |BENCHMARK(BM_SharedPtrCtorDtor);
        43  |
        44  |static void BM_IntrusivePtrArray(benchmark::State& state) {
    >>> 45  |  intrusive_ptr<Foo> var = make_intrusive<Foo>(0);
        46  |  const size_t kLength = state.range(0);
        47  |  std::vector<intrusive_ptr<Foo>> vararray(kLength);
        48  |  while (state.KeepRunning()) {

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'vararray' is not initialized

        44  |static void BM_IntrusivePtrArray(benchmark::State& state) {
        45  |  intrusive_ptr<Foo> var = make_intrusive<Foo>(0);
        46  |  const size_t kLength = state.range(0);
    >>> 47  |  std::vector<intrusive_ptr<Foo>> vararray(kLength);
        48  |  while (state.KeepRunning()) {
        49  |    for (const auto i : c10::irange(kLength)) {
        50  |      vararray[i] = var;

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'vararray' is not initialized

        60  |static void BM_SharedPtrArray(benchmark::State& state) {
        61  |  std::shared_ptr<Bar> var = std::make_shared<Bar>(0);
        62  |  const size_t kLength = state.range(0);
    >>> 63  |  std::vector<std::shared_ptr<Bar>> vararray(kLength);
        64  |  while (state.KeepRunning()) {
        65  |    for (const auto i : c10::irange(kLength)) {
        66  |      vararray[i] = var;



>>> Lint for c10/cuda/CUDAMacros.h:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'c10/cuda/impl/cuda_cmake_macros.h' file not found

         5  |// We have not yet modified the AMD HIP build to generate this file so
         6  |// we add an extra option to specifically ignore it.
         7  |#ifndef C10_CUDA_NO_CMAKE_CONFIGURE_FILE
    >>>  8  |#include <c10/cuda/impl/cuda_cmake_macros.h>
         9  |#endif // C10_CUDA_NO_CMAKE_CONFIGURE_FILE
        10  |
        11  |#endif



>>> Lint for c10/cuda/CUDAStream.h:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'cuda_runtime_api.h' file not found

          3  |#include <cstdint>
          4  |#include <utility>
          5  |
    >>>   6  |#include <cuda_runtime_api.h>
          7  |
          8  |#include <c10/core/DeviceGuard.h>
          9  |#include <c10/core/Stream.h>



>>> Lint for c10/test/core/CompileTimeFunctionPointer_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

         1  |#include <c10/core/CompileTimeFunctionPointer.h>
    >>>  2  |#include <gtest/gtest.h>
         3  |
         4  |namespace test_is_compile_time_function_pointer {
         5  |static_assert(!c10::is_compile_time_function_pointer<void()>::value);

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'executor' is not initialized

        52  |};
        53  |
        54  |TEST(CompileTimeFunctionPointerTest, runFunctionThroughType) {
    >>> 55  |  Executor<Add> executor;
        56  |  EXPECT_EQ(3, executor.execute(1, 2));
        57  |}
        58  |} // namespace test_run_through_type



>>> Lint for c10/test/core/DeviceGuard_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

    >>>  1  |#include <gtest/gtest.h>
         2  |
         3  |#include <c10/core/DeviceGuard.h>
         4  |#include <c10/core/impl/FakeGuardImpl.h>



>>> Lint for c10/test/core/Device_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

    >>>  1  |#include <gtest/gtest.h>
         2  |
         3  |#include <c10/core/Device.h>
         4  |#include <c10/util/Exception.h>

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'valid_devices' is not initialized

        12  |};
        13  |
        14  |TEST(DeviceTest, BasicConstruction) {
    >>> 15  |  std::vector<ExpectedDeviceTestResult> valid_devices = {
        16  |      {"cpu", c10::DeviceType::CPU, -1},
        17  |      {"cuda", c10::DeviceType::CUDA, -1},
        18  |      {"cpu:0", c10::DeviceType::CPU, 0},

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'invalid_device_strings' is not initialized

        19  |      {"cuda:0", c10::DeviceType::CUDA, 0},
        20  |      {"cuda:1", c10::DeviceType::CUDA, 1},
        21  |  };
    >>> 22  |  std::vector<std::string> invalid_device_strings = {
        23  |      "cpu:x",
        24  |      "cpu:foo",
        25  |      "cuda:cuda",



>>> Lint for c10/test/core/DispatchKeySet_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

    >>>   1  |#include <gtest/gtest.h>
          2  |
          3  |#include <cstddef>
          4  |#include <iterator>

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'visited_keys' is not initialized

        251  |      ASSERT_TRUE(combined.has(tid2));
        252  |
        253  |      // Add all of the keys in the keyset to a real set
    >>> 254  |      std::unordered_set<DispatchKey> visited_keys;
        255  |      auto iter = combined.begin();
        256  |      while (*iter != *combined.end()) {
        257  |        visited_keys.insert(*iter);

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'expected_keys' is not initialized

        257  |        visited_keys.insert(*iter);
        258  |        ++iter;
        259  |      }
    >>> 260  |      std::unordered_set<DispatchKey> expected_keys;
        261  |      expected_keys.insert(
        262  |          toRuntimePerBackendFunctionalityKey(functionality1, backend1));
        263  |      expected_keys.insert(

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'seen_strings' is not initialized

        387  |}
        388  |
        389  |TEST(DispatchKeySet, TestBackendComponentToString) {
    >>> 390  |  std::unordered_set<std::string> seen_strings;
        391  |  for (int64_t i = 0;
        392  |       i <= static_cast<int64_t>(BackendComponent::EndOfBackendKeys);
        393  |       i++) {

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'seen_strings' is not initialized

        408  |}
        409  |
        410  |TEST(DispatchKeySet, TestFunctionalityDispatchKeyToString) {
    >>> 411  |  std::unordered_set<std::string> seen_strings;
        412  |  for (int i = 0; i <= static_cast<int>(DispatchKey::EndOfAliasKeys); i++) {
        413  |    auto k = static_cast<DispatchKey>(i);
        414  |    // These synthetic keys never actually get used and don't need



>>> Lint for c10/test/core/SymInt_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

    >>>   1  |#include <gtest/gtest.h>
          2  |
          3  |#include <c10/core/SingletonSymNodeImpl.h>
          4  |#include <c10/core/SymInt.h>



>>> Lint for c10/test/core/impl/InlineDeviceGuard_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

    >>>   1  |#include <gtest/gtest.h>
          2  |#include <initializer_list>
          3  |
          4  |#include <c10/core/impl/FakeGuardImpl.h>

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'init_i' is not initialized

         60  |
         61  |TEST(InlineDeviceGuard, SetDevice) {
         62  |  DeviceIndex init_i = 0;
    >>>  63  |  TestGuardImpl::setDeviceIndex(init_i);
         64  |  DeviceIndex i = 1;
         65  |  TestGuard g(i);
         66  |  DeviceIndex i2 = 2;

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'init_i' is not initialized

         76  |
         77  |TEST(InlineDeviceGuard, ResetDevice) {
         78  |  DeviceIndex init_i = 0;
    >>>  79  |  TestGuardImpl::setDeviceIndex(init_i);
         80  |  DeviceIndex i = 1;
         81  |  TestGuard g(i);
         82  |  DeviceIndex i2 = 2;

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'init_i' is not initialized

         92  |
         93  |TEST(InlineDeviceGuard, SetIndex) {
         94  |  DeviceIndex init_i = 0;
    >>>  95  |  TestGuardImpl::setDeviceIndex(init_i);
         96  |  DeviceIndex i = 1;
         97  |  TestGuard g(i);
         98  |  DeviceIndex i2 = 2;

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'init_i' is not initialized

        145  |
        146  |TEST(InlineOptionalDeviceGuard, NullaryConstructor) {
        147  |  DeviceIndex init_i = 0;
    >>> 148  |  TestGuardImpl::setDeviceIndex(init_i);
        149  |  auto test_body = [&](MaybeTestGuard& g) -> void {
        150  |    ASSERT_EQ(g.original_device(), nullopt);
        151  |    ASSERT_EQ(g.current_device(), nullopt);

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'init_i' is not initialized

        166  |
        167  |TEST(InlineOptionalDeviceGuard, SetDevice) {
        168  |  DeviceIndex init_i = 0;
    >>> 169  |  TestGuardImpl::setDeviceIndex(init_i);
        170  |  MaybeTestGuard g;
        171  |  DeviceIndex i = 1;
        172  |  g.set_device(dev(i));

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'init_i' is not initialized

        181  |
        182  |TEST(InlineOptionalDeviceGuard, SetIndex) {
        183  |  DeviceIndex init_i = 0;
    >>> 184  |  TestGuardImpl::setDeviceIndex(init_i);
        185  |  DeviceIndex i = 1;
        186  |  MaybeTestGuard g;
        187  |  g.set_index(i);



>>> Lint for c10/test/core/impl/InlineStreamGuard_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

    >>>   1  |#include <gtest/gtest.h>
          2  |
          3  |#include <c10/core/impl/FakeGuardImpl.h>
          4  |#include <c10/core/impl/InlineStreamGuard.h>

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'streams' is not initialized

        181  |TEST(InlineMultiStreamGuard, Constructor) {
        182  |  TestGuardImpl::resetStreams();
        183  |  {
    >>> 184  |    std::vector<Stream> streams;
        185  |    MultiTestGuard g(streams);
        186  |    ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(0), 0);
        187  |    ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(1), 0);

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'streams' is not initialized

        189  |  ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(0), 0);
        190  |  ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(1), 0);
        191  |  {
    >>> 192  |    std::vector<Stream> streams = {stream(0, 2)};
        193  |    MultiTestGuard g(streams);
        194  |    ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(0), 2);
        195  |    ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(1), 0);

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'streams' is not initialized

        197  |  ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(0), 0);
        198  |  ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(1), 0);
        199  |  {
    >>> 200  |    std::vector<Stream> streams = {stream(1, 3)};
        201  |    MultiTestGuard g(streams);
        202  |    ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(0), 0);
        203  |    ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(1), 3);

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'streams' is not initialized

        205  |  ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(0), 0);
        206  |  ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(1), 0);
        207  |  {
    >>> 208  |    std::vector<Stream> streams = {stream(0, 2), stream(1, 3)};
        209  |    MultiTestGuard g(streams);
        210  |    ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(0), 2);
        211  |    ASSERT_EQ(TestGuardImpl::getCurrentStreamIdFor(1), 3);



>>> Lint for c10/test/core/impl/SizesAndStrides_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

    >>>   1  |#include <gtest/gtest.h>
          2  |
          3  |#include <c10/core/impl/SizesAndStrides.h>
          4  |#include <c10/util/irange.h>

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'sizes' is not initialized

        205  |}
        206  |
        207  |static void checkSmall(const SizesAndStrides& sm, int offset = 0) {
    >>> 208  |  std::vector<int64_t> sizes(3), strides(3);
        209  |  for (const auto ii : c10::irange(3)) {
        210  |    sizes[ii] = ii + 1 + offset;
        211  |    strides[ii] = 2 * (ii + 1 + offset);

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'sizes' is not initialized

        214  |}
        215  |
        216  |static void checkBig(const SizesAndStrides& big, int offset = 0) {
    >>> 217  |  std::vector<int64_t> sizes(8), strides(8);
        218  |  for (const auto ii : c10::irange(8)) {
        219  |    sizes[ii] = ii - 1 + offset;
        220  |    strides[ii] = 2 * (ii - 1 + offset);



>>> Lint for c10/test/core/impl/cow_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gmock/gmock.h' file not found

          4  |#include <c10/core/CPUAllocator.h>
          5  |#include <c10/core/StorageImpl.h>
          6  |
    >>>   7  |#include <gmock/gmock.h>
          8  |#include <gtest/gtest.h>
          9  |
         10  |#include <cstddef>

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'new_storage' is not initialized

        155  |
        156  |  ASSERT_THAT(original_storage, is_copy_on_write());
        157  |
    >>> 158  |  intrusive_ptr<StorageImpl> new_storage =
        159  |      cow::lazy_clone_storage(original_storage);
        160  |  ASSERT_THAT(new_storage.get(), testing::NotNull());
        161  |



>>> Lint for c10/test/util/Bitset_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

    >>>   1  |#include <gtest/gtest.h>
          2  |
          3  |#include <c10/util/Bitset.h>
          4  |#include <c10/util/irange.h>

  Error (CLANGTIDY) [cppcoreguidelines-pro-type-member-init,-warnings-as-errors]
    constructor does not initialize these fields: called_for_indices

         92  |  }
         93  |}
         94  |
    >>>  95  |struct IndexCallbackMock final {
         96  |  std::vector<size_t> called_for_indices;
         97  |
         98  |  void operator()(size_t index) {



>>> Lint for c10/test/util/DeadlockDetection_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

         1  |#include <c10/util/DeadlockDetection.h>
         2  |
    >>>  3  |#include <gtest/gtest.h>
         4  |
         5  |#include <cstdlib>
         6  |



>>> Lint for c10/test/util/Half_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

          1  |#include <vector>
          2  |
          3  |#include <c10/util/Half.h>
    >>>   4  |#include <gtest/gtest.h>
          5  |
          6  |namespace {
          7  |namespace half_legacy_impl {

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'inputs' is not initialized

         94  |};
         95  |} // namespace half_legacy_impl
         96  |TEST(HalfDoubleConversionTest, Half2Double) {
    >>>  97  |  std::vector<uint16_t> inputs = {
         98  |      0,
         99  |      0xfbff, // 1111 1011 1111 1111
        100  |      (1 << 15 | 1),



>>> Lint for c10/test/util/LeftRight_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

          1  |#include <c10/util/LeftRight.h>
    >>>   2  |#include <gtest/gtest.h>
          3  |#include <vector>
          4  |
          5  |using c10::LeftRight;

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'obj' is not initialized

         19  |}
         20  |
         21  |TEST(LeftRightTest, givenVector_whenWritingAndReading_thenChangesArePresent) {
    >>>  22  |  LeftRight<vector<int>> obj;
         23  |
         24  |  obj.write([](vector<int>& obj) { obj.push_back(5); });
         25  |  vector<int> read = obj.read([](const vector<int>& obj) { return obj; });

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'read' is not initialized

         22  |  LeftRight<vector<int>> obj;
         23  |
         24  |  obj.write([](vector<int>& obj) { obj.push_back(5); });
    >>>  25  |  vector<int> read = obj.read([](const vector<int>& obj) { return obj; });
         26  |  EXPECT_EQ((vector<int>{5}), read);
         27  |
         28  |  obj.write([](vector<int>& obj) { obj.push_back(6); });

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'obj' is not initialized

         31  |}
         32  |
         33  |TEST(LeftRightTest, givenVector_whenWritingReturnsValue_thenValueIsReturned) {
    >>>  34  |  LeftRight<vector<int>> obj;
         35  |
         36  |  auto a = obj.write([](vector<int>&) -> int { return 5; });
         37  |  static_assert(std::is_same<int, decltype(a)>::value);

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'obj' is not initialized

        223  |}
        224  |
        225  |TEST(LeftRightTest, givenVector_whenWriteThrowsException_thenResetsToOldState) {
    >>> 226  |  LeftRight<vector<int>> obj;
        227  |
        228  |  obj.write([](vector<int>& obj) { obj.push_back(5); });
        229  |

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'read' is not initialized

        236  |      MyException);
        237  |
        238  |  // check reading it returns old value
    >>> 239  |  vector<int> read = obj.read([](const vector<int>& obj) { return obj; });
        240  |  EXPECT_EQ((vector<int>{5}), read);
        241  |
        242  |  // check changes are also present in background copy



>>> Lint for c10/test/util/Metaprogramming_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

          1  |#include <c10/test/util/Macros.h>
          2  |#include <c10/util/Metaprogramming.h>
    >>>   3  |#include <gtest/gtest.h>
          4  |#include <cstdlib>
          5  |
          6  |using namespace c10::guts;



>>> Lint for c10/test/util/Synchronized_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

         1  |#include <c10/util/Synchronized.h>
    >>>  2  |#include <gtest/gtest.h>
         3  |
         4  |#include <array>
         5  |#include <thread>



>>> Lint for c10/test/util/ThreadLocal_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

          1  |#include <c10/util/ThreadLocal.h>
    >>>   2  |#include <gtest/gtest.h>
          3  |
          4  |#include <atomic>
          5  |#include <thread>



>>> Lint for c10/test/util/TypeIndex_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

          1  |#include <c10/util/Metaprogramming.h>
          2  |#include <c10/util/TypeIndex.h>
    >>>   3  |#include <gtest/gtest.h>
          4  |
          5  |using c10::string_view;
          6  |using c10::util::get_fully_qualified_type_name;



>>> Lint for c10/test/util/TypeList_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

          1  |#include <c10/util/TypeList.h>
    >>>   2  |#include <gtest/gtest.h>
          3  |#include <memory>
          4  |
          5  |using namespace c10::guts::typelist;



>>> Lint for c10/test/util/TypeTraits_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

          1  |#include <c10/util/TypeTraits.h>
    >>>   2  |#include <gtest/gtest.h>
          3  |
          4  |using namespace c10::guts;
          5  |



>>> Lint for c10/test/util/accumulate_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

         2  |
         3  |#include <c10/util/accumulate.h>
         4  |
    >>>  5  |#include <gtest/gtest.h>
         6  |
         7  |#include <list>
         8  |#include <vector>

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'ints' is not initialized

        10  |using namespace ::testing;
        11  |
        12  |TEST(accumulateTest, vector_test) {
    >>> 13  |  std::vector<int> ints = {1, 2, 3, 4, 5};
        14  |
        15  |  EXPECT_EQ(c10::sum_integers(ints), 1 + 2 + 3 + 4 + 5);
        16  |  EXPECT_EQ(c10::multiply_integers(ints), 1 * 2 * 3 * 4 * 5);

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'ints' is not initialized

        30  |}
        31  |
        32  |TEST(accumulateTest, list_test) {
    >>> 33  |  std::list<int> ints = {1, 2, 3, 4, 5};
        34  |
        35  |  EXPECT_EQ(c10::sum_integers(ints), 1 + 2 + 3 + 4 + 5);
        36  |  EXPECT_EQ(c10::multiply_integers(ints), 1 * 2 * 3 * 4 * 5);

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'ints' is not initialized

        46  |}
        47  |
        48  |TEST(accumulateTest, base_cases) {
    >>> 49  |  std::vector<int> ints = {};
        50  |
        51  |  EXPECT_EQ(c10::sum_integers(ints), 0);
        52  |  EXPECT_EQ(c10::multiply_integers(ints), 1);

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'ints' is not initialized

        53  |}
        54  |
        55  |TEST(accumulateTest, errors) {
    >>> 56  |  std::vector<int> ints = {1, 2, 3, 4, 5};
        57  |
        58  |#ifndef NDEBUG
        59  |  EXPECT_THROW(c10::numelements_from_dim(-1, ints), c10::Error);



>>> Lint for c10/test/util/bfloat16_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

          3  |#include <c10/util/BFloat16-math.h>
          4  |#include <c10/util/irange.h>
          5  |// clang-format on
    >>>   6  |#include <gtest/gtest.h>
          7  |
          8  |namespace {
          9  |float float_from_bytes(uint32_t sign, uint32_t exponent, uint32_t fraction) {



>>> Lint for c10/test/util/bit_cast_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gmock/gmock.h' file not found

         1  |#include <c10/util/bit_cast.h>
         2  |
    >>>  3  |#include <gmock/gmock.h>
         4  |#include <gtest/gtest.h>
         5  |
         6  |#include <cstdint>



>>> Lint for c10/test/util/complex_math_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

    >>> 1  |#include <gtest/gtest.h>
        2  |#define C10_DEFINE_TEST(a, b) TEST(a, b)
        3  |#define C10_ASSERT_NEAR(a, b, tol) ASSERT_NEAR(a, b, tol)
        4  |#include <c10/test/util/complex_math_test_common.h>



>>> Lint for c10/test/util/complex_test_common.h:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

          1  |#include <c10/macros/Macros.h>
          2  |#include <c10/util/complex.h>
          3  |#include <c10/util/hash.h>
    >>>   4  |#include <gtest/gtest.h>
          5  |#include <sstream>
          6  |#include <tuple>
          7  |#include <type_traits>



>>> Lint for c10/test/util/either_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gmock/gmock.h' file not found

           3  |
           4  |#include <c10/macros/Macros.h>
           5  |#include <c10/util/either.h>
    >>>    6  |#include <gmock/gmock.h>
           7  |#include <gtest/gtest.h>
           8  |#include <sstream>
           9  |#include <vector>



>>> Lint for c10/test/util/exception_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

          1  |#include <c10/util/Exception.h>
    >>>   2  |#include <gtest/gtest.h>
          3  |#include <stdexcept>
          4  |
          5  |using c10::Error;



>>> Lint for c10/test/util/flags_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

    >>>  1  |#include <gtest/gtest.h>
         2  |
         3  |#include <iostream>
         4  |



>>> Lint for c10/test/util/intrusive_ptr_test.cpp:

  Error (CLANGTIDY) [clang-diagnostic-error]
    'gtest/gtest.h' file not found

           1  |#include <c10/util/intrusive_ptr.h>
           2  |
    >>>    3  |#include <gtest/gtest.h>
           4  |#include <map>
           5  |#include <set>
           6  |#include <unordered_map>

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'var' is not initialized

          95  |    "intrusive_ptr<T>::element_type is wrong");
          96  |
          97  |TEST(MakeIntrusiveTest, ClassWith0Parameters) {
    >>>   98  |  intrusive_ptr<SomeClass0Parameters> var =
          99  |      make_intrusive<SomeClass0Parameters>();
         100  |  // Check that the type is correct
         101  |  EXPECT_EQ(var.get(), dynamic_cast<SomeClass0Parameters*>(var.get()));

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'var' is not initialized

         102  |}
         103  |
         104  |TEST(MakeIntrusiveTest, ClassWith1Parameter) {
    >>>  105  |  intrusive_ptr<SomeClass1Parameter> var =
         106  |      make_intrusive<SomeClass1Parameter>(5);
         107  |  EXPECT_EQ(5, var->param);
         108  |}

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'var' is not initialized

         108  |}
         109  |
         110  |TEST(MakeIntrusiveTest, ClassWith2Parameters) {
    >>>  111  |  intrusive_ptr<SomeClass2Parameters> var =
         112  |      make_intrusive<SomeClass2Parameters>(7, 2);
         113  |  EXPECT_EQ(7, var->param1);
         114  |  EXPECT_EQ(2, var->param2);

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'var' is not initialized

         121  |}
         122  |
         123  |TEST(MakeIntrusiveTest, CanAssignToBaseClassPtr) {
    >>>  124  |  intrusive_ptr<SomeBaseClass> var = make_intrusive<SomeChildClass>(3);
         125  |  EXPECT_EQ(3, var->v);
         126  |}
         127  |

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'obj' is not initialized

         130  |}
         131  |
         132  |TEST(IntrusivePtrTest, givenValidPtr_whenCallingGet_thenReturnsObject) {
    >>>  133  |  intrusive_ptr<SomeClass1Parameter> obj =
         134  |      make_intrusive<SomeClass1Parameter>(5);
         135  |  EXPECT_EQ(5, obj.get()->param);
         136  |}

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'obj' is not initialized

         136  |}
         137  |
         138  |TEST(IntrusivePtrTest, givenValidPtr_whenCallingConstGet_thenReturnsObject) {
    >>>  139  |  const intrusive_ptr<SomeClass1Parameter> obj =
         140  |      make_intrusive<SomeClass1Parameter>(5);
         141  |  EXPECT_EQ(5, obj.get()->param);
         142  |}

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'obj' is not initialized

         142  |}
         143  |
         144  |TEST(IntrusivePtrTest, givenInvalidPtr_whenCallingGet_thenReturnsNullptr) {
    >>>  145  |  intrusive_ptr<SomeClass1Parameter> obj;
         146  |  EXPECT_EQ(nullptr, obj.get());
         147  |}
         148  |

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'obj' is not initialized

         147  |}
         148  |
         149  |TEST(IntrusivePtrTest, givenNullptr_whenCallingGet_thenReturnsNullptr) {
    >>>  150  |  intrusive_ptr<SomeClass1Parameter> obj(nullptr);
         151  |  EXPECT_EQ(nullptr, obj.get());
         152  |}
         153  |

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'obj' is not initialized

         152  |}
         153  |
         154  |TEST(IntrusivePtrTest, givenValidPtr_whenDereferencing_thenReturnsObject) {
    >>>  155  |  intrusive_ptr<SomeClass1Parameter> obj =
         156  |      make_intrusive<SomeClass1Parameter>(5);
         157  |  EXPECT_EQ(5, (*obj).param);
         158  |}

  Error (CLANGTIDY) [cppcoreguidelines-init-variables,-warnings-as-errors]
    variable 'obj' is not initialized

         158  |}
         159  |
         160  |TEST(IntrusivePtrTest, givenValidPtr_whenConstDereferencing_thenReturnsObject) {
    >>>  161  |  const intrusive_ptr<SomeClass1Parameter> obj =
         162  |      make_intrusive<SomeClass1Parameter>(5);
         163  |  EXPECT_EQ(5, (*obj).param);
         164  |}

// MANUAL: Removing a couple 1000s of errors otherwise this issue is too long


>>> Lint for torch/utils/data/datapipes/datapipe.pyi:

  Error (MYPY) [misc]
    Class torch.utils.data.datapipes.datapipe.DFIterDataPipe has abstract
    attributes "__iter__"

        660  |        """
        661  |    
        662  |
    >>> 663  |class DFIterDataPipe(IterDataPipe):
        664  |    def _is_dfpipe(self): ...
        665  |
        666  |class _DataPipeSerializationWrapper:



>>> Lint for torch/utils/data/datapipes/iter/combining.py:

  Error (MYPY) [abstract]
    Cannot instantiate abstract class "_ForkerIterDataPipe" with abstract
    attribute "__iter__"

        103  |            raise ValueError(f"Expected `num_instances` larger than 0, but {num_instances} is found")
        104  |        if num_instances == 1:
        105  |            return datapipe
    >>> 106  |        container = _ForkerIterDataPipe(datapipe, num_instances, buffer_size, copy)
        107  |        return [_ChildDataPipe(container, i) for i in range(num_instances)]
        108  |
        109  |

  Error (MYPY) [abstract]
    Cannot instantiate abstract class "_DemultiplexerIterDataPipe" with
    abstract attribute "__iter__"

        395  |        # When num_instances == 1, demux can be replaced by filter,
        396  |        # but keep it as Demultiplexer for the sake of consistency
        397  |        # like throwing Error when classification result is out of o range
    >>> 398  |        container = _DemultiplexerIterDataPipe(datapipe, num_instances, classifier_fn, drop_none, buffer_size)
        399  |        return [_ChildDataPipe(container, i) for i in range(num_instances)]
        400  |
        401  |

```

</details>