aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2023-07-30 20:28:59 -0400
committerDylan Baker <dylan@pnwbakers.com>2023-07-31 11:00:22 -0700
commitd4615369ffbfc0f9a769ca1fd3566056cfa5ef81 (patch)
tree86e7999158fb1615ba84a78f6dd939ea33040532
parent404312c6ddc44b1e8f09a95a5c889184a25a384b (diff)
downloadmeson-d4615369ffbfc0f9a769ca1fd3566056cfa5ef81.zip
meson-d4615369ffbfc0f9a769ca1fd3566056cfa5ef81.tar.gz
meson-d4615369ffbfc0f9a769ca1fd3566056cfa5ef81.tar.bz2
fix lint errors revealed by pycodestyle 2.11
When performing isinstance checks, an identity comparison is automatically done, but we don't use isinstance here because we need strict identity equality *without allowing subtypes*. Comparing type() == type() is a value comparison, but could produce effectively the same results as an identity comparison, usually, despite being semantically off. pycodestyle learned to detect this and warn you to do strict identity comparison.
-rw-r--r--mesonbuild/coredata.py2
-rw-r--r--mesonbuild/interpreterbase/baseobjects.py8
2 files changed, 5 insertions, 5 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index a6178f0..54d9b1d 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -807,7 +807,7 @@ class CoreData:
continue
oldval = self.options[key]
- if type(oldval) != type(value):
+ if type(oldval) is not type(value):
self.options[key] = value
elif oldval.choices != value.choices:
# If the choices have changed, use the new value, but attempt
diff --git a/mesonbuild/interpreterbase/baseobjects.py b/mesonbuild/interpreterbase/baseobjects.py
index d5b8c94..4966978 100644
--- a/mesonbuild/interpreterbase/baseobjects.py
+++ b/mesonbuild/interpreterbase/baseobjects.py
@@ -119,12 +119,12 @@ class InterpreterObject:
# We use `type(...) == type(...)` here to enforce an *exact* match for comparison. We
# don't want comparisons to be possible where `isinstance(derived_obj, type(base_obj))`
# would pass because this comparison must never be true: `derived_obj == base_obj`
- if type(self) != type(other):
+ if type(self) is not type(other):
self._throw_comp_exception(other, '==')
return self == other
def op_not_equals(self, other: TYPE_var) -> bool:
- if type(self) != type(other):
+ if type(self) is not type(other):
self._throw_comp_exception(other, '!=')
return self != other
@@ -157,12 +157,12 @@ class ObjectHolder(InterpreterObject, T.Generic[InterpreterObjectTypeVar]):
# Override default comparison operators for the held object
def op_equals(self, other: TYPE_var) -> bool:
# See the comment from InterpreterObject why we are using `type()` here.
- if type(self.held_object) != type(other):
+ if type(self.held_object) is not type(other):
self._throw_comp_exception(other, '==')
return self.held_object == other
def op_not_equals(self, other: TYPE_var) -> bool:
- if type(self.held_object) != type(other):
+ if type(self.held_object) is not type(other):
self._throw_comp_exception(other, '!=')
return self.held_object != other