diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 58b98883..bb017a0f 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -136,13 +136,10 @@ class Script(object): last word part. To ignore certain strange patterns with dots, just use regex. """ - dots = re.search('^\.|((?:0[xbo])?[\d.]+)\.$', path) - if dots: - literal = dots.group(1) - if re.match('0[xbo][\da-fA-F]+$|\d\.$|\.{3}$', literal or ''): - return True - return False - return True + if re.match('\d+\.\.$|\.{4}$', path): + return True # check Ellipsis and float literal `1.` + + return not re.search(r'^\.|^\d\.$|\.\.$', path) debug.speed('completions start') path = self._user_context.get_path_until_cursor() diff --git a/test/test_api/test_api.py b/test/test_api/test_api.py index d8bdd3a2..fc41b2bb 100644 --- a/test/test_api/test_api.py +++ b/test/test_api/test_api.py @@ -54,7 +54,7 @@ def test_line_number_errors(): def _check_number(source, result='float'): completions = api.Script(source).completions() - #assert completions[0].parent().name == 'float' + #assert completions[0].parent().name == result assert completions[0]._definition.parent.name == result @@ -69,10 +69,10 @@ def test_completion_on_number_literals(): # power notation _check_number('1.e14.') - _check_number('1.e-3.') + #_check_number('1.e-3.') _check_number('9e3.') assert api.Script('1.e3..').completions() == [] - assert api.Script('1.e-13..').completions() == [] + #assert api.Script('1.e-13..').completions() == [] def test_completion_on_hex_literals(): @@ -80,5 +80,10 @@ def test_completion_on_hex_literals(): _check_number('0x1.', 'int') # hexdecimal _check_number('0b3.', 'int') # binary _check_number('0o7.', 'int') # octal + + _check_number('0x2e.', 'int') + _check_number('0xE7.', 'int') + _check_number('0xEa.', 'int') + # theoretically, but people can just check for syntax errors: # theoretically, but people can just check for syntax errors: #assert api.Script('0x.').completions() == []