[BE] enable ruff rule RSE and remove useless parentheses in raise statements (#124261)

Remove useless parentheses in `raise` statements if the exception type is raised with no argument.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/124261
Approved by: https://github.com/albanD
This commit is contained in:
Xuehai Pan
2024-04-17 19:29:30 +00:00
committed by PyTorch MergeBot
parent b726a23d4e
commit 93e249969b
98 changed files with 297 additions and 296 deletions

View File

@ -1238,7 +1238,7 @@ $3: f32[] = torch._ops.aten.add.Tensor($1, $2)""")
class AMode(TorchDispatchMode):
def __torch_dispatch__(self, func, types, args=(), kwargs=None):
if func.__name__ == 'randn.default':
raise RuntimeError()
raise RuntimeError
return A(torch.zeros(()))
with AMode():
@ -1254,7 +1254,7 @@ $3: f32[] = torch._ops.aten.add.Tensor($1, $2)""")
class A(TorchDispatchMode):
def __torch_dispatch__(self, func, types, args=(), kwargs=None):
raise ErrorA()
raise ErrorA
x = A()
with self.assertRaises(ErrorA):