Update ruff linter for PEP585 (#147540)

This turns on PEP585 enforcement in RUFF.

- Updates the target python version
- Stops ignoring UP006 warnings (PEP585)
- Fixes a few issues which crept into the tree in the last day

Pull Request resolved: https://github.com/pytorch/pytorch/pull/147540
Approved by: https://github.com/justinchuby, https://github.com/Skylion007
This commit is contained in:
Aaron Orenstein
2025-02-21 07:57:30 -08:00
committed by PyTorch MergeBot
parent 77d2780657
commit 086d146f6f
19 changed files with 131 additions and 88 deletions

View File

@ -255,9 +255,11 @@ class TestForeach(TestCase):
else inputs
)
try:
with InplaceForeachVersionBumpCheck(
self, inputs[0]
) if op.is_inplace else nullcontext():
with (
InplaceForeachVersionBumpCheck(self, inputs[0])
if op.is_inplace
else nullcontext()
):
actual = op(inputs, self.is_cuda, is_fastpath)
except RuntimeError as e:
with self.assertRaisesRegex(type(e), re.escape(str(e).splitlines()[0])):
@ -278,9 +280,11 @@ class TestForeach(TestCase):
try:
op_kwargs = {}
op_kwargs.update(kwargs)
with InplaceForeachVersionBumpCheck(
self, inputs[0]
) if op.is_inplace else nullcontext():
with (
InplaceForeachVersionBumpCheck(self, inputs[0])
if op.is_inplace
else nullcontext()
):
actual = op(inputs, self.is_cuda, is_fastpath, **op_kwargs)
except RuntimeError as e:
with self.assertRaisesRegex(type(e), re.escape(str(e).splitlines()[0])):