Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looks like jedi is not handling f-strings properly #13

Closed
viniarck opened this issue Feb 2, 2019 · 2 comments
Closed

Looks like jedi is not handling f-strings properly #13

viniarck opened this issue Feb 2, 2019 · 2 comments

Comments

@viniarck
Copy link

viniarck commented Feb 2, 2019

If you try autocompletion on this snippet, just try to insert an extra " in the printf(f"wh line, you'll see that jedi is returning bad results, looks like jedi doesn't fully support f-strings yet:

#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    """Main function."""
    print(f"wh)


if __name__ == "__main__":
    main()

2019-02-02 08:47:03,905 [INFO @ ncm2_jedi.py:on_complete:54] 15064 - context [{'filepath': '/home/viniarck/repos/algos-structures-python/f_strs.py', 'typed': '    print(f"wh', 'scope_match': 'python', 'startccol': 13, 'mode': 'i', 'word_pattern': '(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\\'\\"\\,\\.\\<\\>\\/\\?\\s]+)', 'time': 1549104423.904316, 'lnum': 7, 'bufnr': 2, 'changedtick': 157, 'manual': False, 'base': 'wh', 'ccol': 15, 'filetype': 'python', 'curpos': [0, 7, 15, 0, 15], 'tick': [[0, 7, 15], 0], 'early_cache': False, 'context_id': 119, 'scope': 'python', 'matcher': {'name': 'abbrfuzzy'}, 'source': {'subscope_enable': 1, 'early_cache': 0, 'name': 'jedi', 'scope': ['python'], 'mark': 'py', 'on_warmup': 'ncm2_jedi#on_warmup', 'ready': 1, 'enable': 1, 'auto_popup': 1, 'priority': 9, 'complete_pattern': ['^\\s*(import|from).*\\s', '\\.', '\\(\\s?', ',\\s?'], 'on_complete': 'ncm2_jedi#on_complete'}, 'scope_level': 1, 'bcol': 15, 'match_end': 12}]
2019-02-02 08:47:03,906 [WARNING @ session.py:handler:221] 15064 - error caught while processing notification 'b'on_complete' [{b'filepath': b'/home/viniarck/repos/algos-structures-python/f_strs.py', b'typed': b'    print(f"wh', b'scope_match': b'python', b'startccol': 13, b'mode': b'i', b'word_pattern': b'(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\\'\\"\\,\\.\\<\\>\\/\\?\\s]+)', b'time': 1549104423.904316, b'lnum': 7, b'bufnr': 2, b'changedtick': 157, b'manual': False, b'base': b'wh', b'ccol': 15, b'filetype': b'python', b'curpos': [0, 7, 15, 0, 15], b'tick': [[0, 7, 15], 0], b'early_cache': False, b'context_id': 119, b'scope': b'python', b'matcher': {b'name': b'abbrfuzzy'}, b'source': {b'subscope_enable': 1, b'early_cache': 0, b'name': b'jedi', b'scope': [b'python'], b'mark': b'py', b'on_warmup': b'ncm2_jedi#on_warmup', b'ready': 1, b'enable': 1, b'auto_popup': 1, b'priority': 9, b'complete_pattern': [b'^\\s*(import|from).*\\s', b'\\.', b'\\(\\s?', b',\\s?'], b'on_complete': b'ncm2_jedi#on_complete'}, b'scope_level': 1, b'bcol': 15, b'match_end': 12}, [b'#!/usr/bin/env python', b'# -*- coding: utf-8 -*-', b'', b'', b'def main():', b'    """Main function."""', b'    print(f"wh)', b'', b'', b'if __name__ == "__main__":', b'    main()']]': Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/pynvim/msgpack_rpc/session.py", line 217, in handler
    self._notification_cb(name, args)
  File "/usr/lib/python3.7/site-packages/pynvim/api/nvim.py", line 222, in filter_notification_cb
    notification_cb(name, args)
  File "/home/viniarck/.config/nvim/.cache/init.vim/.dein/pythonx/yarp.py", line 36, in on_notification
    getattr(module_obj, method)(*args)
  File "/home/viniarck/.dotfiles/roles/dotfiles/files/config/nvim/.cache/init.vim/.dein/pythonx/ncm2.py", line 203, in on_complete
    on_complete_impl(context, *args)
  File "/home/viniarck/.config/nvim/repos/github.com/ncm2/ncm2-jedi/pythonx/ncm2_jedi.py", line 88, in on_complete
    completions = script.completions()
  File "/home/viniarck/.local/lib/python3.7/site-packages/jedi/api/__init__.py", line 174, in completions
    completions = completion.completions()
  File "/home/viniarck/.local/lib/python3.7/site-packages/jedi/api/completion.py", line 98, in completions
    completion_names = self._get_context_completions()
  File "/home/viniarck/.local/lib/python3.7/site-packages/jedi/api/completion.py", line 126, in _get_context_completions
    grammar, self._code_lines, self._module_node, self._position
  File "/home/viniarck/.local/lib/python3.7/site-packages/jedi/api/helpers.py", line 130, in get_stack_at_position
    raise SystemError("This really shouldn't happen. There's a bug in Jedi.")
SystemError: This really shouldn't happen. There's a bug in Jedi.

I'm using ncm2-jedi commit 0003b01 to reproduce this.

@roxma
Copy link
Member

roxma commented Feb 3, 2019

hmm... Canot reproduce

https://asciinema.org/a/3uGLLFMkRELRccapu3bdI4pjD

@viniarck
Copy link
Author

viniarck commented Feb 3, 2019

Hi @roxma, it turns out this problem doesn't happen with the latest version of jedi. I just upgraded from version 0.12.1 to 0.13.2 and it works. So, I'm closing this issue and also the the PR #14.

Thanks.

@viniarck viniarck closed this as completed Feb 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants