Commit 5c848acb authored by Tzer-jen Wei's avatar Tzer-jen Wei

can handle conflicting types now

parent 46441912
......@@ -84,7 +84,7 @@ class TestJediTyper(TransformTest):
self.assertFalse(types)
self.assertEqual({'a': set(['int']), 'i': set(['int'])}, variables)
def _test_conflicting_types_in_function(self):
def test_conflicting_types_in_function(self):
code = '''\
def func(a, b):
print(a)
......@@ -99,7 +99,7 @@ class TestJediTyper(TransformTest):
self.assertIn(('func', (1, 0)), types)
variables = types.pop(('func', (1, 0)))
self.assertFalse(types)
self.assertEqual({'a': set(['int', 'str']), 'i': set(['int'])}, variables)
self.assertEqual({'a': set(['float', 'int', 'str']), 'b': set(['int'])}, variables)
def _test_typing_function_char_loop(self):
code = '''\
......
......@@ -44,9 +44,11 @@ def analyse(source_path=None, code=None):
try:
names = scoped_names[key]
except KeyError:
names = scoped_names[key] = defaultdict(set)
names = scoped_names[key] = defaultdict(set)
position = statement.start_pos if statement.name in names else None
for name_type in evaluator.find_types(scope, statement.name, search_global=True):
for name_type in evaluator.find_types(scope, statement.name, position=position ,search_global=True):
if isinstance(name_type, Instance):
if isinstance(name_type.base, Class):
type_name = 'object'
......
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