mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
PEP585 update - benchmarks tools torchgen (#145101)
This is one of a series of PRs to update us to PEP585 (changing Dict -> dict, List -> list, etc). Most of the PRs were completely automated with RUFF as follows: Since RUFF UP006 is considered an "unsafe" fix first we need to enable unsafe fixes: ``` --- a/tools/linter/adapters/ruff_linter.py +++ b/tools/linter/adapters/ruff_linter.py @@ -313,6 +313,7 @@ "ruff", "check", "--fix-only", + "--unsafe-fixes", "--exit-zero", *([f"--config={config}"] if config else []), "--stdin-filename", ``` Then we need to tell RUFF to allow UP006 (as a final PR once all of these have landed this will be made permanent): ``` --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ [tool.ruff] -target-version = "py38" +target-version = "py39" line-length = 88 src = ["caffe2", "torch", "torchgen", "functorch", "test"] @@ -87,7 +87,6 @@ "SIM116", # Disable Use a dictionary instead of consecutive `if` statements "SIM117", "SIM118", - "UP006", # keep-runtime-typing "UP007", # keep-runtime-typing ] select = [ ``` Finally running `lintrunner -a --take RUFF` will fix up the deprecated uses. Pull Request resolved: https://github.com/pytorch/pytorch/pull/145101 Approved by: https://github.com/bobrenjc93
This commit is contained in:
committed by
PyTorch MergeBot
parent
2c4281d7da
commit
07669ed960
@ -3,8 +3,9 @@ import logging
|
||||
import math
|
||||
import os
|
||||
from collections import Counter, defaultdict
|
||||
from collections.abc import Generator, Iterable
|
||||
from functools import partial
|
||||
from typing import Any, Dict, Generator, Iterable
|
||||
from typing import Any
|
||||
|
||||
import torch
|
||||
from torch.testing import make_tensor
|
||||
@ -263,7 +264,7 @@ class OperatorInputsLoader:
|
||||
|
||||
def get_inputs_for_operator(
|
||||
self, operator, dtype=None, device="cuda"
|
||||
) -> Generator[tuple[Iterable[Any], Dict[str, Any]], None, None]:
|
||||
) -> Generator[tuple[Iterable[Any], dict[str, Any]], None, None]:
|
||||
assert (
|
||||
str(operator) in self.operator_db
|
||||
), f"Could not find {operator}, must provide overload"
|
||||
|
Reference in New Issue
Block a user