[BE]: Update flake8 to v6.1.0 and fix lints (#116591)

Updates flake8 to v6.1.0 and fixes a few lints using sed and some ruff tooling.
- Replace `assert(0)` with `raise AssertionError()`
- Remove extraneous parenthesis i.e.
  - `assert(a == b)` -> `assert a == b`
  - `if(x > y or y < z):`->`if x > y or y < z:`
  - And `return('...')` -> `return '...'`

Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>

Pull Request resolved: https://github.com/pytorch/pytorch/pull/116591
Approved by: https://github.com/albanD, https://github.com/malfet
This commit is contained in:
Aaron Gokaslan
2024-01-03 06:04:44 +00:00
committed by PyTorch MergeBot
parent 09ee96b69d
commit 3fe437b24b
62 changed files with 188 additions and 190 deletions

View File

@ -217,7 +217,7 @@ class SubTensor(torch.Tensor):
"""
@classmethod
def __torch_function__(cls, func, types, args=(), kwargs=None):
if(kwargs is None):
if kwargs is None:
kwargs = {}
if func not in HANDLED_FUNCTIONS_SUB:
@ -368,7 +368,7 @@ class TensorLike:
"""
@classmethod
def __torch_function__(cls, func, types, args=(), kwargs=None):
if(kwargs is None):
if kwargs is None:
kwargs = {}
if func not in HANDLED_FUNCTIONS_TENSOR_LIKE: