Commit 3817aa59 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

division_support: record the status of each modification

parent c671076a
......@@ -8,15 +8,23 @@ from my2to3.trace import get_data
from my2to3.util import add_future, data2types
def analyze_types(types):
"""Indicates whether the division described by `data` should be modified into
`//`, or should remain as `/`
"""
# id is used to differentiate the divisions of the same line.
insert_support = create_table("division_support", "filename", "lineno", "id", "status")
def analyze_data(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:
return True
return False
return True, "automatic"
return False, "manual"
class FixDivisionSupport(BaseFix):
......@@ -35,7 +43,9 @@ class FixDivisionSupport(BaseFix):
if not data:
return
if analyze_types(data2types(data)):
should_change, status = analyze_data(data)
insert_support(filename, lineno, id_, status)
if should_change:
add_future(node, 'division')
operator = Leaf(lib2to3.pgen2.token.DOUBLESLASH, "//")
else:
......
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