[5/N] Apply ruff UP035 rule (#164423)

Continued code migration to enable ruff `UP035`. Most changes are about moving `Callable` from `typing` to `from collections.abc`.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/164423
Approved by: https://github.com/ezyang
This commit is contained in:
Yuanyuan Chen
2025-10-02 07:31:11 +00:00
committed by PyTorch MergeBot
parent bcafea5c92
commit a43c4c3972
113 changed files with 243 additions and 179 deletions

View File

@ -15,8 +15,17 @@ import typing
import weakref
from collections import defaultdict
from dataclasses import dataclass
from typing import Any, Callable, cast, Literal, Optional, TYPE_CHECKING, TypeVar, Union
from typing_extensions import Self, TypeGuard
from typing import (
Any,
cast,
Literal,
Optional,
TYPE_CHECKING,
TypeGuard,
TypeVar,
Union,
)
from typing_extensions import Self
from weakref import ReferenceType
import torch
@ -53,7 +62,7 @@ from ._fake_tensor_utils import _CacheKeyState, _PySymInputStub, _SymIntOutputSt
if TYPE_CHECKING:
from collections.abc import Generator, Iterable, Mapping, Sequence
from collections.abc import Callable, Generator, Iterable, Mapping, Sequence
from types import TracebackType
from torch._guards import Source