mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Enable ruff rule E721 (#165162)
`E721` checks for object type comparisons using == and other comparison operators. This is useful because it is recommended to use `is` for type comparisons. Pull Request resolved: https://github.com/pytorch/pytorch/pull/165162 Approved by: https://github.com/Skylion007
This commit is contained in:
committed by
PyTorch MergeBot
parent
220a34118f
commit
9e7c19f72b
@ -367,7 +367,7 @@ class DeepSpeech(nn.Module):
|
||||
"""
|
||||
seq_len = input_length
|
||||
for m in self.conv.modules():
|
||||
if type(m) == nn.modules.conv.Conv2d:
|
||||
if type(m) is nn.modules.conv.Conv2d:
|
||||
seq_len = (
|
||||
seq_len
|
||||
+ 2 * m.padding[1]
|
||||
|
@ -66,7 +66,7 @@ class GroupedSetup:
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
for field in dataclasses.fields(self):
|
||||
assert field.type == str
|
||||
assert field.type is str
|
||||
value: str = getattr(self, field.name)
|
||||
object.__setattr__(self, field.name, textwrap.dedent(value))
|
||||
|
||||
|
@ -113,7 +113,7 @@ class TorchBenchmarkBase(torch.nn.Module):
|
||||
value = kargs[key]
|
||||
test_name_str.append(
|
||||
("" if key in skip_key_list else key)
|
||||
+ str(value if type(value) != bool else int(value))
|
||||
+ str(value if type(value) is not bool else int(value))
|
||||
)
|
||||
name = (self.module_name() + "_" + "_".join(test_name_str)).replace(" ", "")
|
||||
return name
|
||||
|
@ -125,7 +125,7 @@ class CatBenchmark(op_bench.TorchBenchmarkBase):
|
||||
random.seed(42)
|
||||
inputs = []
|
||||
gen_sizes = []
|
||||
if type(sizes) == list and N == -1:
|
||||
if type(sizes) is list and N == -1:
|
||||
gen_sizes = sizes
|
||||
else:
|
||||
for i in range(N):
|
||||
|
@ -61,7 +61,7 @@ class StackBenchmark(op_bench.TorchBenchmarkBase):
|
||||
random.seed(42)
|
||||
inputs = []
|
||||
gen_sizes = []
|
||||
if type(sizes) == list and N == -1:
|
||||
if type(sizes) is list and N == -1:
|
||||
gen_sizes = sizes
|
||||
else:
|
||||
for i in range(N):
|
||||
|
Reference in New Issue
Block a user