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

division_support: record when there's no data

parent f5adf0ab
...@@ -13,18 +13,21 @@ insert_support = create_table("division_support", "filename", "lineno", "id", "s ...@@ -13,18 +13,21 @@ insert_support = create_table("division_support", "filename", "lineno", "id", "s
def analyze_data(data): def analyze_data(data):
if not data:
return False, "no data"
try: try:
types = data2types(data) types = data2types(data)
except Exception as e: except Exception as e:
# Probably, one type is not a builtins # Probably, one type is not a builtins
return False, "unknown" return False, "unknown"
else:
if len(types) == 1:
dividend, divisor = types[0]
if dividend is divisor is int:
return True, "automatic"
return False, "manual" if len(types) == 1:
dividend, divisor = types[0]
if dividend is divisor is int:
return True, "automatic"
return False, "manual"
class FixDivisionSupport(BaseFix): class FixDivisionSupport(BaseFix):
...@@ -39,11 +42,13 @@ class FixDivisionSupport(BaseFix): ...@@ -39,11 +42,13 @@ class FixDivisionSupport(BaseFix):
def transform(self, node, results): def transform(self, node, results):
filename, lineno, id_ = [l.value for l in node.children[1].children[1].children[:-4:2]] 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_)) should_change, status = analyze_data(
if not data: get_data(
return "division_trace",
["dividend_type", "divisor_type"],
should_change, status = analyze_data(data) dict(filename=filename, lineno=lineno, id=id_)
)
)
insert_support(filename, lineno, id_, status) insert_support(filename, lineno, id_, status)
if should_change: if should_change:
add_future(node, 'division') 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