1
0
forked from VimPlug/jedi

If branch inference should not trigger for things we don't know, fixes #1530

This commit is contained in:
Dave Halter
2020-03-31 22:46:17 +02:00
parent 604029568c
commit ac33d5dea3
4 changed files with 19 additions and 3 deletions

View File

@@ -603,7 +603,11 @@ def _infer_comparison_part(inference_state, context, left, operator, right):
if str_operator in ('is', '!=', '==', 'is not'):
operation = COMPARISON_OPERATORS[str_operator]
bool_ = operation(left, right)
return ValueSet([_bool_to_value(inference_state, bool_)])
# Only if == returns True or != returns False, we can continue.
# There's no guarantee that they are not equal. This can help
# in some cases, but does not cover everything.
if (str_operator in ('is', '==')) == bool_:
return ValueSet([_bool_to_value(inference_state, bool_)])
if isinstance(left, VersionInfo):
version_info = _get_tuple_ints(right)