mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[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:
committed by
PyTorch MergeBot
parent
bcafea5c92
commit
a43c4c3972
@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import functools
|
||||
from typing import Any, Callable, Optional, TYPE_CHECKING, TypeVar, Union
|
||||
from typing import Any, Optional, TYPE_CHECKING, TypeVar, Union
|
||||
|
||||
import torchgen.local as local
|
||||
from torchgen.model import (
|
||||
@ -16,7 +16,7 @@ from torchgen.utils import context, S, T
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterator
|
||||
from collections.abc import Callable, Iterator
|
||||
|
||||
|
||||
# Helper functions for defining generators on things in the model
|
||||
|
@ -8,7 +8,7 @@ import os
|
||||
from collections import defaultdict, namedtuple, OrderedDict
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Literal, TYPE_CHECKING, TypeVar
|
||||
from typing import Any, Literal, TYPE_CHECKING, TypeVar
|
||||
from typing_extensions import assert_never
|
||||
|
||||
import yaml
|
||||
@ -96,7 +96,7 @@ from torchgen.yaml_utils import YamlDumper, YamlLoader
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Callable, Sequence
|
||||
from typing import Optional
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Callable, Optional, TYPE_CHECKING
|
||||
from typing import Optional, TYPE_CHECKING
|
||||
|
||||
from torchgen.api import cpp, dispatcher, functionalization
|
||||
from torchgen.api.translate import translate
|
||||
@ -51,6 +51,8 @@ from torchgen.utils import concatMap, dataclass_repr, FileManager
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Callable
|
||||
|
||||
from torchgen.selective_build.selector import SelectiveBuilder
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ import argparse
|
||||
import os
|
||||
from collections import namedtuple
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, TYPE_CHECKING
|
||||
from typing import Any, TYPE_CHECKING
|
||||
|
||||
import yaml
|
||||
|
||||
@ -26,7 +26,7 @@ from torchgen.yaml_utils import YamlLoader
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterable, Iterator, Sequence
|
||||
from collections.abc import Callable, Iterable, Iterator, Sequence
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
|
@ -5,14 +5,14 @@ import itertools
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
from enum import auto, Enum
|
||||
from typing import Callable, Optional, TYPE_CHECKING
|
||||
from typing import Optional, TYPE_CHECKING
|
||||
from typing_extensions import assert_never
|
||||
|
||||
from torchgen.utils import NamespaceHelper, OrderedSet
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterator, Sequence
|
||||
from collections.abc import Callable, Iterator, Sequence
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
|
@ -11,7 +11,7 @@ from dataclasses import is_dataclass
|
||||
from enum import auto, Enum
|
||||
from pathlib import Path
|
||||
from pprint import pformat
|
||||
from typing import Any, Callable, Generic, NoReturn, TYPE_CHECKING, TypeVar
|
||||
from typing import Any, Generic, NoReturn, TYPE_CHECKING, TypeVar
|
||||
from typing_extensions import assert_never, deprecated, Self
|
||||
|
||||
from torchgen.code_template import CodeTemplate
|
||||
@ -19,7 +19,7 @@ from torchgen.code_template import CodeTemplate
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from argparse import Namespace
|
||||
from collections.abc import Iterable, Iterator, Sequence
|
||||
from collections.abc import Callable, Iterable, Iterator, Sequence
|
||||
|
||||
|
||||
TORCHGEN_ROOT = Path(__file__).absolute().parent
|
||||
|
Reference in New Issue
Block a user