[1/N] Apply py39 ruff fixes (#138578)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/138578
Approved by: https://github.com/Skylion007
This commit is contained in:
cyy
2024-12-02 21:46:15 +00:00
committed by PyTorch MergeBot
parent b47bdb06d8
commit 55250b324d
26 changed files with 118 additions and 42 deletions

View File

@ -10,18 +10,7 @@ import textwrap
from dataclasses import fields, is_dataclass
from enum import auto, Enum
from pathlib import Path
from typing import (
Any,
Callable,
Generic,
Iterable,
Iterator,
Literal,
NoReturn,
Sequence,
TYPE_CHECKING,
TypeVar,
)
from typing import Any, Callable, Generic, Literal, NoReturn, TYPE_CHECKING, TypeVar
from typing_extensions import Self
from torchgen.code_template import CodeTemplate
@ -29,6 +18,7 @@ from torchgen.code_template import CodeTemplate
if TYPE_CHECKING:
from argparse import Namespace
from collections.abc import Iterable, Iterator, Sequence
REPO_ROOT = Path(__file__).absolute().parent.parent
@ -113,7 +103,7 @@ def assert_never(x: NoReturn) -> NoReturn:
raise AssertionError(f"Unhandled type: {type(x).__name__}")
@functools.lru_cache(maxsize=None)
@functools.cache
def _read_template(template_fn: str) -> CodeTemplate:
return CodeTemplate.from_file(template_fn)