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
Tab completions for paths broken again in 7.2.0 #11530
Comments
I have the same issue, ipython 7.2.0. |
Downgrading to ipython==7.1.1 seemed to work as a fix for me. |
Could someone share if enabling It certainly made my life much harder: no multi-level completion, no folder completion, nor can I use autocompletion before running the cell ( |
The bug certainly has made my life much harder as well. auto-completion is probably one of the most important feature of an interactive shell. Is there a way jedi and path auto-completion can coexist? |
For those who have run into issues with downgrading, I found @ivirshup's comment to be most helpful - to disable # Generate config
ipython profile create
# Edit config file in vim
vim .ipython/profile_default/ipython_kernel_config.py And change |
Nonono. It’s not the jedi completer that does that. There’s multiple completers and you’re describing that the wrong completer is selected because the completer selection code is broken. And touching the list of completers by enabling jedi uncovered that bug. @takluyver describes the problem in #10996 (comment). Disabling jedi again is a temporary workaround, but actually fixing the completer selection code (#11064 I think) would of course be a much better solution. |
My understanding is that all the completers are working at the same time. Completers are defined here, and they are all used at the same time. The So the path/file name completion is not "broken" when jedi is enabled, it is just that there is so many results (coming from jedi) that you can't see your file path matching anymore. My first idea for a fix would be to disable jedi auto-completion when typing in a string? Would that work? EDIT: Reading the other issue you linked to @flying-sheep #11064, I understand that there is already a logic for not using jedi when typing in a string, but it is broken? |
If there were a way to remove all builtins from autocompletion, and all ipython magic - it would be already much better! I know how to type 'abs', and most of us can type it in several times faster than selecting it from autocompletion list. I'm not sure there is a good reason for it, and other 3-4 letter long builtins, to be there in a first place! Ideally, if there were a way to edit the list of builtins, I would just leave a few long names that I use, like DepercationWarning, and get rid of everything else. |
Just look at the use case in the image: Why would I want to type a Python object name inside of a string literal? |
I can find a simple use case: exec("print(abs(-3))", [globals()]) Maybe it is a less common use case, but it can happen. I would agree that path completion is more important than this use case for most of the users. |
Yeah, it is a possibility, and some people rely on exec a lot. Ideally, autocomplete should detect that it is in a filename mode, and from there on function like a normal bash tab completion. A good proxy is starting with "/", "./" or "C:" "D:" etc. It is even less likely that string starting with these variables would contain valid python expressions. I'm sure one can make an example of |
Yeah, actually the code is supposed to skip jedi completion when you are typing a string. See this line: ipython/IPython/core/completer.py Line 1375 in 65778ad
And it relies on jedi internal parsing logic for trying to figure it out if we are in a string or not. I tested this code a bit and it turns out that it is a bit broken, for example when typing path = " it will see that you are in a string, but not with path = "./ . I guess we can come up with a better solution using tokenize.
|
Is it because Jedi doesn't think it is an ErrorLeaf, or is it because going back by two nodes is insufficient? |
I'm not sure, and I quickly switched my mind to |
tokenize has its problem too. What if the cell raises an IndentationError or SyntaxError before the string opening? You may need to backtrack lines gradually, but then you are always expecting an error near the cursor due to the incomplete string declaration? |
With tokenize I'm thinking of a simple logic like it is done in Also another idea could be to use regexp, I would be useless in this case though :P |
I guess it would just not complete... What is the current behavior? Does the autocompletion still work when you have a SyntaxError in your code? We should check |
Same issue after updating to 7.3.0. |
IIRC I'm not sure what it would do with something like an unterminated string on the line before, which might be a syntax error at the tokenisation level. |
Similar issues with the latest conda installation:
I actually get no tab completion at all. Only within a function (shift+double-tab) do I get the docstring completion. No method completion on objects at all. Typing paths within strings does work as expected i.e. no global variables listed. |
Issue remains in IPython 7.7.0 installed via conda:
|
And it will until this issue and #10926 are closed. @JeremySikes73 and me gave some explanation there of what’s wrong, and I’m pretty sure the issue is the same: IPython’s matchers all return results while we should either a) run only the relevant ones or b) add code to the matchers that makes them return nothing when their results would be irrelevant. Thank you for trying to help, but I think it’s more productive to read #10926, dive into the code and find out how to improve the situation than saying “it’s still an issue”. |
@meeseeksdev tag help wanted |
@meeseeksdev tag tab-completion |
Which file to edit? |
A temporary workaround for this problem is to append a second slash after pressing tab. Once an item is selected, there will only be a single slash as separator: Note that adding the second slash before pressing tab does not change the pop up menu. |
I upgraded to the latest version of ipython as of today (7.11.0), and the problem still persists. |
@flying-sheep @augustogoulart Are you open to pull requests on this? (I mean, the "helpwanted" tag suggests so, but I'm not an existing contributor so not sure of the developer norms here.) I have some minor changes to the logic in the detection of whether we are in a string or not, which, while not a perfect fix, at least does a better job of turning off jedi. This doesn't completely fix #10926 or this, since it would be nice to turn off (in my opinion):
but it does at least turn off jedi when in a string, which goes a long way in making my own use patterns workable. |
I’m just a small-time contributor myself, but I bet they’d like help to fix this! |
Updating IPython - 7.20.0, resolved for me. Regards |
The issue isn't fully fixed in 7.20.0. Path completion kind of works, if you start with import IPython.core.completer
def _magic_matches(self, text):
return []
IPython.core.completer.IPCompleter.magic_matches = _magic_matches In your Unfortunately, the |
Tab completion for paths within strings seems to be broken again (previously noted many places, like #10961, #10996, notebook issue #3333). Here's what I get in
v7.2.0
:Compared to the behavior in
v7.1.1
:Probably related to #11503, as disabling Jedi (setting
c.IPCompleter.use_jedi = False
inipython_config.py
) gives the correct behavior.System info
The text was updated successfully, but these errors were encountered: