diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 4c408877..58b98883 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -136,11 +136,10 @@ class Script(object): last word part. To ignore certain strange patterns with dots, just use regex. """ - dots = re.search('^\.|([\d.]+)\.$', path) + dots = re.search('^\.|((?:0[xbo])?[\d.]+)\.$', path) if dots: literal = dots.group(1) - print(literal) - if re.search('\d\.|\.{3}', literal or ''): + if re.match('0[xbo][\da-fA-F]+$|\d\.$|\.{3}$', literal or ''): return True return False return True diff --git a/test/test_api/test_api.py b/test/test_api/test_api.py index 15334781..d8bdd3a2 100644 --- a/test/test_api/test_api.py +++ b/test/test_api/test_api.py @@ -70,14 +70,15 @@ def test_completion_on_number_literals(): # power notation _check_number('1.e14.') _check_number('1.e-3.') + _check_number('9e3.') assert api.Script('1.e3..').completions() == [] assert api.Script('1.e-13..').completions() == [] -def test_completion_on_complex_literals(): - assert api.Script('1j..').completions() == [] - _check_number('1j.', 'complex') - _check_number('44.j.', 'complex') - _check_number('4.0j.', 'complex') - # No dot no completion - assert api.Script('4j').completions() == [] +def test_completion_on_hex_literals(): + assert api.Script('0x1..').completions() == [] + _check_number('0x1.', 'int') # hexdecimal + _check_number('0b3.', 'int') # binary + _check_number('0o7.', 'int') # octal + # theoretically, but people can just check for syntax errors: + #assert api.Script('0x.').completions() == []