Skip to content

Commit 820e078

Browse files
committed
Use identity checks
1 parent 925ffef commit 820e078

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

astroid/constraint.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def match(
7878
def satisfied_by(self, inferred: InferenceResult) -> bool:
7979
"""Return True if this constraint is satisfied by the given inferred value."""
8080
# Assume true if uninferable
81-
if isinstance(inferred, util.UninferableBase):
81+
if inferred is util.Uninferable:
8282
return True
8383

8484
# Return the XOR of self.negate and matches(inferred, self.CONST_NONE)
@@ -118,9 +118,7 @@ def satisfied_by(self, inferred: InferenceResult) -> bool:
118118
- negate=True: satisfied if boolean value is False
119119
"""
120120
inferred_booleaness = inferred.bool_value()
121-
if isinstance(inferred, util.UninferableBase) or isinstance(
122-
inferred_booleaness, util.UninferableBase
123-
):
121+
if inferred is util.Uninferable or inferred_booleaness is util.Uninferable:
124122
return True
125123

126124
return self.negate ^ inferred_booleaness
@@ -160,14 +158,14 @@ def satisfied_by(self, inferred: InferenceResult) -> bool:
160158
- negate=False: satisfied when inferred is an instance of the checked types.
161159
- negate=True: satisfied when inferred is not an instance of the checked types.
162160
"""
163-
if isinstance(inferred, util.UninferableBase):
161+
if inferred is util.Uninferable:
164162
return True
165163

166164
try:
167165
types = helpers.class_or_tuple_to_container(self.classinfo)
168166
matches_checked_types = helpers.object_isinstance(inferred, types)
169167

170-
if isinstance(matches_checked_types, util.UninferableBase):
168+
if matches_checked_types is util.Uninferable:
171169
return True
172170

173171
return self.negate ^ matches_checked_types

0 commit comments

Comments
 (0)