Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apex/contrib/gpu_direct_storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

@contextmanager
def GDSFile(filename, mode):
assert type(filename) == str
assert type(mode) == str
assert isinstance(filename, str)
assert isinstance(mode, str)
try:
from apex import deprecated_warning

Expand Down
4 changes: 2 additions & 2 deletions apex/contrib/optimizers/fused_adam.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def step(self, closure=None, grads=None, output_params=None, scale=1.0, grad_nor
# assuming a list/generator of parameter means single group
elif isinstance(grads, types.GeneratorType):
grads_group = [grads]
elif type(grads[0]) != list:
elif not isinstance(grads[0], list):
grads_group = [grads]
else:
grads_group = grads
Expand All @@ -115,7 +115,7 @@ def step(self, closure=None, grads=None, output_params=None, scale=1.0, grad_nor
output_params_group = [None] * len(self.param_groups)
elif isinstance(output_params, types.GeneratorType):
output_params_group = [output_params]
elif type(output_params[0]) != list:
elif not isinstance(output_params[0], list):
output_params_group = [output_params]
else:
output_params_group = output_params
Expand Down
4 changes: 2 additions & 2 deletions apex/contrib/optimizers/fused_sgd.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def step(self, closure=None, grads=None, output_params=None, scale=1.0, grad_nor
# assuming a list/generator of parameter means single group
elif isinstance(grads, types.GeneratorType):
grads_group = [grads]
elif type(grads[0]) != list:
elif not isinstance(grads[0], list):
grads_group = [grads]
else:
grads_group = grads
Expand All @@ -170,7 +170,7 @@ def step(self, closure=None, grads=None, output_params=None, scale=1.0, grad_nor
)
elif isinstance(output_params, types.GeneratorType):
output_params_group = [output_params]
elif type(output_params[0]) != list:
elif not isinstance(output_params[0], list):
output_params_group = [output_params]
else:
output_params_group = output_params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def destroy_pg_upon_exit(self) -> bool:

def _create_process_group_nccl(self):
def maybe_export(env, val):
if not type(env) == str:
if not isinstance(env, str):
raise ValueError(f"Type of type of env is expected to be str, but got {type(env)}")
if not type(val) == str:
if not isinstance(val, str):
raise ValueError(f"Type of type of val is expected to be str, but got {type(val)}")
if os.getenv(env) is None:
os.environ[env] = val
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ line-length = 100
ignore = [
# Sorted by occurrence count (ascending) - easier to fix first
"E731", # lambda assignment (6 occurrences)
"E721", # type comparison should use isinstance (8 occurrences)
"E741", # ambiguous variable name (8 occurrences)
"E712", # comparison to True/False (9 occurrences)
"F403", # star imports used (9 occurrences)
Expand Down