Merge pull request #2014 from WutingjiaX/feat/in_operator

When inferring comparison operators, return a definite type instead of NO_VALUES for the in/not in operator
This commit is contained in:
Dave Halter
2024-07-10 18:03:32 +00:00
committed by GitHub
3 changed files with 12 additions and 1 deletions
+1
View File
@@ -64,6 +64,7 @@ Code Contributors
- Joseph Birkner (@josephbirkner) - Joseph Birkner (@josephbirkner)
- Márcio Mazza (@marciomazza) - Márcio Mazza (@marciomazza)
- Martin Vielsmaier (@moser) <martin@vielsmaier.net> - Martin Vielsmaier (@moser) <martin@vielsmaier.net>
- TingJia Wu (@WutingjiaX) <wutingjia@bytedance.com>
And a few more "anonymous" contributors. And a few more "anonymous" contributors.
+4 -1
View File
@@ -645,7 +645,10 @@ def _infer_comparison_part(inference_state, context, left, operator, right):
_bool_to_value(inference_state, False) _bool_to_value(inference_state, False)
]) ])
elif str_operator in ('in', 'not in'): elif str_operator in ('in', 'not in'):
return NO_VALUES return ValueSet([
_bool_to_value(inference_state, True),
_bool_to_value(inference_state, False)
])
def check(obj): def check(obj):
"""Checks if a Jedi object is either a float or an int.""" """Checks if a Jedi object is either a float or an int."""
+7
View File
@@ -424,3 +424,10 @@ with open("a"), open("b") as bfile:
some_array = ['', ''] some_array = ['', '']
#! ['def upper'] #! ['def upper']
some_array[some_not_defined_index].upper some_array[some_not_defined_index].upper
# -----------------
# operator
# -----------------
#? bool()
res = 'f' in 'foo'; res