Skip to content

Commit 1126e5a

Browse files
aliafzalfacebook-github-bot
authored andcommitted
Fix Python Flake8 lint error E721. (#3402)
Summary: Lint error E721 occurs when the type() function is used for type comparison instead of the more flexible isinstance(). The isinstance() function can handle subclasses as well. The codemod only replaces type() function with isinstance() function for type comparison and preserves the existing code functionality while improving code extensibility for future changes. Differential Revision: D83559508
1 parent 61bf3cf commit 1126e5a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torchrec/distributed/tests/test_dynamic_sharding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def are_sharded_ebc_modules_identical(
206206
val2 = getattr(module2, attr)
207207

208208
assert type(val1) is type(val2)
209-
if type(val1) is torch.Tensor:
209+
if isinstance(val1, torch.Tensor):
210210
torch.testing.assert_close(val1, val2)
211211
else:
212212
assert val1 == val2

0 commit comments

Comments
 (0)