Skip to content

Commit cb8ebdb

Browse files
committed
Add a couple of Uninferable filters where we weren't using any
1 parent 660c15d commit cb8ebdb

File tree

6 files changed

+14
-9
lines changed

6 files changed

+14
-9
lines changed

pylint/checkers/classes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ def _check_slots(self, node):
799799

800800
def _check_slots_elt(self, elt):
801801
for infered in elt.infer():
802-
if infered is astroid.YES:
802+
if infered is astroid.Uninferable:
803803
continue
804804
if (not isinstance(infered, astroid.Const) or
805805
not isinstance(infered.value, six.string_types)):
@@ -1172,7 +1172,7 @@ def _check_init(self, node):
11721172
return
11731173
try:
11741174
for klass in expr.expr.infer():
1175-
if klass is astroid.YES:
1175+
if klass is astroid.Uninferable:
11761176
continue
11771177
# The infered klass can be super(), which was
11781178
# assigned to a variable and the `__init__`

pylint/checkers/python3.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ def _check_dict_node(node):
4242
inferred_types = set()
4343
try:
4444
inferred = node.infer()
45-
for inferred_node in inferred:
46-
inferred_types.add(inferred_node)
45+
if inferred is not astroid.Uninferable:
46+
for inferred_node in inferred:
47+
inferred_types.add(inferred_node)
4748
except astroid.InferenceError:
4849
pass
4950
return (not inferred_types
@@ -740,6 +741,8 @@ def visit_call(self, node):
740741
inferred_types = set()
741742
try:
742743
for inferred_receiver in node.func.expr.infer():
744+
if inferred_receiver is astroid.Uninferable:
745+
continue
743746
inferred_types.add(inferred_receiver)
744747
if isinstance(inferred_receiver, astroid.Module):
745748
self._warn_if_deprecated(node, inferred_receiver.name,

pylint/checkers/stdlib.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ def visit_call(self, node):
193193
"""Visit a Call node."""
194194
try:
195195
for inferred in node.func.infer():
196+
if inferred is astroid.Uninferable:
197+
continue
196198
if inferred.root().name == OPEN_MODULE:
197199
if getattr(node.func, 'name', None) in OPEN_FILES:
198200
self._check_open_mode(node)

pylint/checkers/strings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def _check_new_format_specifiers(self, node, fields, named):
450450
argument = next(argname.infer())
451451
except astroid.InferenceError:
452452
continue
453-
if not specifiers or argument is astroid.YES:
453+
if not specifiers or argument is astroid.Uninferable:
454454
# No need to check this key if it doesn't
455455
# use attribute / item access
456456
continue
@@ -461,7 +461,7 @@ def _check_new_format_specifiers(self, node, fields, named):
461461
previous = argument
462462
parsed = []
463463
for is_attribute, specifier in specifiers:
464-
if previous is astroid.YES:
464+
if previous is astroid.Uninferable:
465465
break
466466
parsed.append((is_attribute, specifier))
467467
if is_attribute:

pylint/checkers/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ def node_type(node):
820820
types = set()
821821
try:
822822
for var_type in node.infer():
823-
if var_type == astroid.YES or is_none(var_type):
823+
if var_type == astroid.Uninferable or is_none(var_type):
824824
continue
825825
types.add(var_type)
826826
if len(types) > 1:

pylint/checkers/variables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def _check_all(self, node, not_consumed):
460460
elt_name = next(elt.infer())
461461
except astroid.InferenceError:
462462
continue
463-
if elt_name is astroid.YES:
463+
if elt_name is astroid.Uninferable:
464464
continue
465465
if not elt_name.parent:
466466
continue
@@ -1222,7 +1222,7 @@ def _check_module_attrs(self, node, module, module_names):
12221222
break
12231223
try:
12241224
module = next(module.getattr(name)[0].infer())
1225-
if module is astroid.YES:
1225+
if module is astroid.Uninferable:
12261226
return None
12271227
except astroid.NotFoundError:
12281228
if module.name in self._ignored_modules:

0 commit comments

Comments
 (0)