[4/N] Apply py39 ruff and pyupgrade fixes (#143257)

```torch/fx/passes/annotate_getitem_nodes.py``` was changed to support the new type hinting annotations.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/143257
Approved by: https://github.com/justinchuby, https://github.com/albanD
This commit is contained in:
cyy
2025-01-04 10:47:51 +00:00
committed by PyTorch MergeBot
parent a881954b0c
commit df458be4e5
55 changed files with 247 additions and 227 deletions

View File

@ -1,7 +1,7 @@
# Owner(s): ["oncall: distributed"]
import unittest
from typing import List, Optional, Tuple
from typing import Optional
import torch
import torch.distributed
@ -27,9 +27,9 @@ class MyModule(torch.nn.Module):
class MyDummyFnOptimizer:
def __init__(
self,
params: List[Tensor],
params: list[Tensor],
lr: float = 1e-3,
betas: Tuple[float, float] = (0.9, 0.999),
betas: tuple[float, float] = (0.9, 0.999),
eps: float = 1e-6,
weight_decay: float = 0.0,
_allow_empty_param_list: bool = False,
@ -63,7 +63,7 @@ class MyDummyFnOptimizer:
"MyDummyFnOptimizer does not support step_param() as of now"
)
def step(self, gradients: List[Optional[Tensor]]):
def step(self, gradients: list[Optional[Tensor]]):
# call the custom optimizer step implementation
with torch.no_grad():
raise RuntimeError("MyDummyFnOptimizer does not support step() as of now")