mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[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:
@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user