Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 33254f2

Browse files
authored
Fix E721 type comparisons (#2003)
1 parent 064d6d5 commit 33254f2

5 files changed

Lines changed: 8 additions & 9 deletions

File tree

apex/contrib/gpu_direct_storage/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
@contextmanager
66
def GDSFile(filename, mode):
7-
assert type(filename) == str
8-
assert type(mode) == str
7+
assert isinstance(filename, str)
8+
assert isinstance(mode, str)
99
try:
1010
from apex import deprecated_warning
1111

apex/contrib/optimizers/fused_adam.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def step(self, closure=None, grads=None, output_params=None, scale=1.0, grad_nor
106106
# assuming a list/generator of parameter means single group
107107
elif isinstance(grads, types.GeneratorType):
108108
grads_group = [grads]
109-
elif type(grads[0]) != list:
109+
elif not isinstance(grads[0], list):
110110
grads_group = [grads]
111111
else:
112112
grads_group = grads
@@ -115,7 +115,7 @@ def step(self, closure=None, grads=None, output_params=None, scale=1.0, grad_nor
115115
output_params_group = [None] * len(self.param_groups)
116116
elif isinstance(output_params, types.GeneratorType):
117117
output_params_group = [output_params]
118-
elif type(output_params[0]) != list:
118+
elif not isinstance(output_params[0], list):
119119
output_params_group = [output_params]
120120
else:
121121
output_params_group = output_params

apex/contrib/optimizers/fused_sgd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def step(self, closure=None, grads=None, output_params=None, scale=1.0, grad_nor
157157
# assuming a list/generator of parameter means single group
158158
elif isinstance(grads, types.GeneratorType):
159159
grads_group = [grads]
160-
elif type(grads[0]) != list:
160+
elif not isinstance(grads[0], list):
161161
grads_group = [grads]
162162
else:
163163
grads_group = grads
@@ -170,7 +170,7 @@ def step(self, closure=None, grads=None, output_params=None, scale=1.0, grad_nor
170170
)
171171
elif isinstance(output_params, types.GeneratorType):
172172
output_params_group = [output_params]
173-
elif type(output_params[0]) != list:
173+
elif not isinstance(output_params[0], list):
174174
output_params_group = [output_params]
175175
else:
176176
output_params_group = output_params

apex/contrib/test/openfold_triton/test_sync_triton_auto_tune_cache_across_gpus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ def destroy_pg_upon_exit(self) -> bool:
4545

4646
def _create_process_group_nccl(self):
4747
def maybe_export(env, val):
48-
if not type(env) == str:
48+
if not isinstance(env, str):
4949
raise ValueError(f"Type of type of env is expected to be str, but got {type(env)}")
50-
if not type(val) == str:
50+
if not isinstance(val, str):
5151
raise ValueError(f"Type of type of val is expected to be str, but got {type(val)}")
5252
if os.getenv(env) is None:
5353
os.environ[env] = val

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ line-length = 100
1010
ignore = [
1111
# Sorted by occurrence count (ascending) - easier to fix first
1212
"E731", # lambda assignment (6 occurrences)
13-
"E721", # type comparison should use isinstance (8 occurrences)
1413
"E741", # ambiguous variable name (8 occurrences)
1514
"E712", # comparison to True/False (9 occurrences)
1615
"F403", # star imports used (9 occurrences)

0 commit comments

Comments
 (0)