15
15
from typing import TYPE_CHECKING , Any , Union
16
16
17
17
import astroid
18
- from astroid import bases , nodes
18
+ from astroid import bases , nodes , util
19
19
from astroid .nodes import LocalsDictNodeNG
20
20
from astroid .typing import SuccessfulInferenceResult
21
21
@@ -459,7 +459,7 @@ def _is_attribute_property(name: str, klass: nodes.ClassDef) -> bool:
459
459
return False
460
460
property_name = "builtins.property"
461
461
for attr in attributes :
462
- if attr is astroid . Uninferable :
462
+ if isinstance ( attr , util . UninferableBase ) :
463
463
continue
464
464
try :
465
465
inferred = next (attr .infer ())
@@ -1453,7 +1453,7 @@ def _check_slots(self, node: nodes.ClassDef) -> None:
1453
1453
1454
1454
for slots in node .ilookup ("__slots__" ):
1455
1455
# check if __slots__ is a valid type
1456
- if slots is astroid . Uninferable :
1456
+ if isinstance ( slots , util . UninferableBase ) :
1457
1457
continue
1458
1458
if not is_iterable (slots ) and not is_comprehension (slots ):
1459
1459
self .add_message ("invalid-slots" , node = node )
@@ -1471,7 +1471,7 @@ def _check_slots(self, node: nodes.ClassDef) -> None:
1471
1471
values = [item [0 ] for item in slots .items ]
1472
1472
else :
1473
1473
values = slots .itered ()
1474
- if values is astroid . Uninferable :
1474
+ if isinstance ( values , util . UninferableBase ) :
1475
1475
continue
1476
1476
for elt in values :
1477
1477
try :
@@ -1518,7 +1518,7 @@ def _check_slots_elt(
1518
1518
self , elt : SuccessfulInferenceResult , node : nodes .ClassDef
1519
1519
) -> None :
1520
1520
for inferred in elt .infer ():
1521
- if inferred is astroid . Uninferable :
1521
+ if isinstance ( inferred , util . UninferableBase ) :
1522
1522
continue
1523
1523
if not isinstance (inferred , nodes .Const ) or not isinstance (
1524
1524
inferred .value , str
@@ -1623,8 +1623,7 @@ def _check_invalid_class_object(self, node: nodes.AssignAttr) -> None:
1623
1623
else :
1624
1624
inferred = safe_infer (node .parent .value )
1625
1625
if (
1626
- isinstance (inferred , nodes .ClassDef )
1627
- or inferred is astroid .Uninferable
1626
+ isinstance (inferred , (nodes .ClassDef , util .UninferableBase ))
1628
1627
or inferred is None
1629
1628
):
1630
1629
# If is uninferable, we allow it to prevent false positives
@@ -2133,7 +2132,7 @@ def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> No
2133
2132
# pylint: disable = too-many-try-statements
2134
2133
try :
2135
2134
for klass in expr .expr .infer ():
2136
- if klass is astroid . Uninferable :
2135
+ if isinstance ( klass , util . UninferableBase ) :
2137
2136
continue
2138
2137
# The inferred klass can be super(), which was
2139
2138
# assigned to a variable and the `__init__`
0 commit comments