Commit 186b2cb6 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

division_support: record when there's no data

parent f5adf0ab
......@@ -13,12 +13,15 @@ insert_support = create_table("division_support", "filename", "lineno", "id", "s
def analyze_data(data):
if not data:
return False, "no data"
try:
types = data2types(data)
except Exception as e:
# Probably, one type is not a builtins
return False, "unknown"
else:
if len(types) == 1:
dividend, divisor = types[0]
if dividend is divisor is int:
......@@ -39,11 +42,13 @@ class FixDivisionSupport(BaseFix):
def transform(self, node, results):
filename, lineno, id_ = [l.value for l in node.children[1].children[1].children[:-4:2]]
data = get_data("division_trace", ["dividend_type", "divisor_type"], dict(filename=filename, lineno=lineno, id=id_))
if not data:
return
should_change, status = analyze_data(data)
should_change, status = analyze_data(
get_data(
"division_trace",
["dividend_type", "divisor_type"],
dict(filename=filename, lineno=lineno, id=id_)
)
)
insert_support(filename, lineno, id_, status)
if should_change:
add_future(node, 'division')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment