[BE] Enable ruff's UP rules and autoformat nn/ mps/ and torch/ (#105436)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/105436
Approved by: https://github.com/malfet, https://github.com/albanD
This commit is contained in:
Justin Chu
2023-07-20 21:56:13 -07:00
committed by PyTorch MergeBot
parent 322dff475c
commit 79c5e33349
89 changed files with 296 additions and 320 deletions

View File

@ -99,7 +99,7 @@ class _StorageBase:
return str(self)
def __iter__(self):
return iter((self[i] for i in range(self.size())))
return iter(self[i] for i in range(self.size()))
def __copy__(self):
return self.clone()
@ -784,7 +784,7 @@ class TypedStorage:
def __iter__(self):
_warn_typed_storage_removal()
return iter((self[i] for i in range(self.size())))
return iter(self[i] for i in range(self.size()))
def __copy__(self):
_warn_typed_storage_removal()
@ -943,13 +943,13 @@ class TypedStorage:
else:
if dtype is not None or len(args) == 5:
raise RuntimeError((
raise RuntimeError(
"from_buffer: 'dtype' can only be specified in "
"UntypedStorage.from_buffer and TypedStorage.from_buffer"))
"UntypedStorage.from_buffer and TypedStorage.from_buffer")
if device is not None:
raise RuntimeError((
raise RuntimeError(
"from_buffer: 'device' can only be specified in "
"UntypedStorage.from_buffer and TypedStorage.from_buffer"))
"UntypedStorage.from_buffer and TypedStorage.from_buffer")
dtype = cls._dtype
untyped_storage = torch.UntypedStorage.from_buffer(*args, dtype=dtype, **kwargs)