Skip to content

Commit

Permalink
Fix flake8 complaint: use 'is' for type comarisons
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Aug 1, 2023
1 parent ffcabba commit a4840e0
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion loopy/kernel/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ def __eq__(self, other):
is_tuple_of_expressions_equal as istoee,
is_expression_equal as isee)
return (
type(self) == type(other)
type(self) is type(other)
and self.name == other.name
and self.dtype == other.dtype
and istoee(self.shape, other.shape)
Expand Down
2 changes: 1 addition & 1 deletion loopy/kernel/instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def update_persistent_hash(self, key_hash, key_builder):
key_builder.rec(key_hash, self.var_name)

def __eq__(self, other):
return (type(self) == type(other)
return (type(self) is type(other)
and self.var_name == other.var_name)

def __ne__(self, other):
Expand Down
6 changes: 3 additions & 3 deletions loopy/library/reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __hash__(self):
return hash((type(self),))

def __eq__(self, other):
return type(self) == type(other)
return type(self) is type(other)

def __str__(self):
result = type(self).__name__.replace("ReductionOperation", "").lower()
Expand Down Expand Up @@ -359,7 +359,7 @@ def __hash__(self):
return hash(type(self))

def __eq__(self, other):
return type(self) == type(other) and (self.inner_reduction ==
return type(self) is type(other) and (self.inner_reduction ==
other.inner_reduction)

def __call__(self, dtypes, operand1, operand2, callables_table, target):
Expand Down Expand Up @@ -461,7 +461,7 @@ def __hash__(self):
return hash(type(self))

def __eq__(self, other):
return type(self) == type(other)
return type(self) is type(other)

@property
def arg_count(self):
Expand Down
16 changes: 8 additions & 8 deletions loopy/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def update_persistent_hash(self, key_hash, key_builder):
key_builder.rec(key_hash, "all_match_expr")

def __eq__(self, other):
return (type(self) == type(other))
return type(self) is type(other)

def __hash__(self):
return hash(type(self))
Expand All @@ -172,7 +172,7 @@ def update_persistent_hash(self, key_hash, key_builder):
key_builder.rec(key_hash, self.children)

def __eq__(self, other):
return (type(self) == type(other)
return (type(self) is type(other)
and self.children == other.children)

def __hash__(self):
Expand Down Expand Up @@ -207,7 +207,7 @@ def update_persistent_hash(self, key_hash, key_builder):
key_builder.rec(key_hash, self.child)

def __eq__(self, other):
return (type(self) == type(other)
return (type(self) is type(other)
and self.child == other.child)

def __hash__(self):
Expand Down Expand Up @@ -253,7 +253,7 @@ def update_persistent_hash(self, key_hash, key_builder):
key_builder.rec(key_hash, self.glob)

def __eq__(self, other):
return (type(self) == type(other)
return (type(self) is type(other)
and self.glob == other.glob)

def __hash__(self):
Expand Down Expand Up @@ -434,7 +434,7 @@ def update_persistent_hash(self, key_hash, key_builder):
key_builder.rec(key_hash, "all_match")

def __eq__(self, other):
return (type(self) == type(other))
return type(self) is type(other)


class StackBottomMatchComponent(StackMatchComponent):
Expand All @@ -445,7 +445,7 @@ def update_persistent_hash(self, key_hash, key_builder):
key_builder.rec(key_hash, "bottom_match")

def __eq__(self, other):
return (type(self) == type(other))
return type(self) is type(other)


class StackItemMatchComponent(StackMatchComponent):
Expand All @@ -469,7 +469,7 @@ def update_persistent_hash(self, key_hash, key_builder):
key_builder.rec(key_hash, self.inner_match)

def __eq__(self, other):
return (type(self) == type(other)
return (type(self) is type(other)
and self.match_expr == other.match_expr
and self.inner_match == other.inner_match)

Expand Down Expand Up @@ -514,7 +514,7 @@ def update_persistent_hash(self, key_hash, key_builder):

def __eq__(self, other):
return (
type(self) == type(other)
type(self) is type(other)
and
self.root_component == other.root_component)

Expand Down
2 changes: 1 addition & 1 deletion loopy/target/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def update_persistent_hash(self, key_hash, key_builder):
key_builder.rec(key_hash, getattr(self, field_name))

def __eq__(self, other):
if type(self) != type(other):
if type(self) is not type(other):
return False

for field_name in self.comparison_fields:
Expand Down
2 changes: 1 addition & 1 deletion loopy/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(self, expression):
self.expression = expression

def __eq__(self, other):
return (type(self) == type(other)
return (type(self) is type(other)
and self.expression == other.expression)

def __ne__(self, other):
Expand Down
4 changes: 2 additions & 2 deletions loopy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def update_persistent_hash(self, key_hash, key_builder):

def __eq__(self, other):
return (
type(self) == type(other)
type(self) is type(other)
and self.dtype == other.dtype)

def __ne__(self, other):
Expand Down Expand Up @@ -192,7 +192,7 @@ def __hash__(self):

def __eq__(self, other):
return (
type(self) == type(other)
type(self) is type(other)
and self.name == other.name)

def __ne__(self, other):
Expand Down

0 comments on commit a4840e0

Please sign in to comment.