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
import validator "can't import" when it should have succeeded #488
Comments
Besides, I found a strange thing: If I comment out the first two lines of # from django.shortcuts import render
# from django.http import HttpResponse
def home_page(request):
return HttpResponse('<html><title>To-Do lists</title></html>') the If I add the first line back from django.shortcuts import render
# from django.http import HttpResponse
def home_page(request):
return HttpResponse('<html><title>To-Do lists</title></html>') then the validator fails. It can only detect It I comment out the first line and add the second line back from django.shortcuts import render
# from django.http import HttpResponse
def home_page(request):
return HttpResponse('<html><title>To-Do lists</title></html>') then the validator fails. It can only detect If I add the first two lines back, from django.shortcuts import render
from django.http import HttpResponse
def home_page(request):
return HttpResponse('<html><title>To-Do lists</title></html>') the validator fails. It can only detect That's quite weird. |
FYI: I checked the project I wrote before, which absolutely went smoothly using Anaconda and I haven't made any changes in it. To my surprise, Anaconda failed in the same way in that project, too. |
To summarize the problem:
|
Hi, I will take a look on this as soon as I can. |
I could not replicate the problem as it has been described in the issue, anyway, I found that sometimes Jedi fails to imports modules in some cases with specific relative imports. Sadly I am not able to offer a satisfactory solution yet to this problem. |
Hey, I managed to consistently replicate the problem, but I couldn't fix it. Here are the source files: |
Interesting. Did you noticed if there was any exceptions being logged into your logs while you were recording the video? |
I just tested again while looking at the console... There's no exception, error or anything out of the ordinary. Do I have to be in debug mode to see it? |
I mean this logs @Effenberg0x0 https://github.com/DamnWidget/anaconda#anaconda-behaves-slowly-and-jsonserver-crashes |
Oh, sorry. Just tailed it. All I see are INFO logging msgs, no errors or exceptions of any kind. When I replicate the exact thing you see in the GIF above, I get apparently normal "client requests: autocomplete" and the answers (completion options) match what we see in screen in the GIF. |
I can confirm that jedi returns the proper completions when the import statement in my_package.my_module is either commented or not commented.
|
I found another interesting thing, still using the example I posted above. In other words, completion works properly for a couple seconds after jsonserver.py is started. |
What happens if you disable the import validations and just autocomplete that module? |
Same exact behavior: No proper completions unless I comment out the import statement in the imported module. |
To add more information into this. if you start ST3 with This is a weird one. |
I was wondering, it's kind of a big one. Shouldn't we be seeing more people complaining about this? Maybe it doesn't affect all platforms? I'm testing on Linux only. |
I will check in OS X and Windows later in home |
I can confirm that behaviour is consistently reproducible in both OS X and Windows 10 |
Ok. I'm not really familiar with the code base, but I'll try to understand On Tue, Nov 8, 2016, 15:46 Oscar Campos notifications@github.com wrote:
|
I rolled back each commit and tested with the python source files I posted here to see when the bug was introduced. This is very weird but I have verified that the bug was actually introduced by commit dd960dc ("anaconda JsonServer totally decoupled from anaconda ST3 plugin (contained on anaconda still)"), back in August 2014! I have no idea how no one (including me) noticed it until now. Anyway, the problem now is that this is a huge commit, there's a lot to learn and a lot to check. If I had to take a wild guess: I noticed listeners.linting.BackgroundLinter() methods make repeated calls to anaconda_lib.helpers.check_linting(), and if I comment out all those if statements and just make it return True, it seems to kinda improve it. Maybe something is wrong with those bitwise AND flags logic? @DamnWidget, any thoughts? Am I close to it? :) |
Hard to say Alvaro, I am still struggling myself to understand how the linting could affect in any way the auto completion as they are completely decoupled features, one should not affect the other. I have no idea how Jedi could stop giving us results after any linting option is used. If I was you, I would start adding some logging verbosity into the jedi handler in the anaconda_server so you can see what the Jedi library is doing and how it behaves. For me is a big mystery how this could be happening, unfortunately I don't have many time now and I have lot of work to do. I hope you can find a solution, I will provide you all the guidance that I could. |
Guys, this totally looks like a bug in jedi, you can confirm it following the steps below in an IPython or Python REPL and the files that @Effenberg0x0 provided (here) : a = 'from my_package.my_module import MyModule'
b = 'import logging'
import jedi
print(jedi.Script(a, 1, 37, '<your_own_path_to_files>/bug_main.py').goto_assignments())
print(jedi.Script(b, 1, 10, '<your_own_path_to_files>/my_package/my_module.py').goto_assignments()) Until here everything is fun and happy, but if you try to get the assignments for the a again: print(jedi.Script(a, 1, 37, '<your_own_path_to_files>/bug_main.py').goto_assignments()) You get an empty list. Actually I "fixed" it in anaconda, and I double quote the word fixed because is just a workaround that uses the Jedi API wrong just not specifying a file path to the The "fix" will be released later today/ |
That's great Oscar :) I have been working my way through Anaconda's code base for some days and trying many different things with no luck at all. Thank you! |
Could you kindly confirm that this issue has been resolved in 2.1.8? Thank you. |
Hi Oscar, there was a tiny typo that caused Anaconda to not be loaded. I submitted a pull request. Other than that, preliminary tests suggest you fixed it. |
I just merged your PR, how are we looking? |
I installed Sublime Text 3 fresh on a new Ubuntu VM and installed Anaconda via Package Control. I think everything is fine :) |
If @jt-wang is still around. can you please confirm and close? |
@DamnWidget Yes. It is perfect now. Many thanks for your effort @DamnWidget @Effenberg0x0 |
The
import validator
gives an error for the following line:The
import validator
fails to recognize the function/class/variable that I declare time to time. Sometimes it works and successfully in validation, but most of the time it fails and gives an error saying "can't import home_page".The text was updated successfully, but these errors were encountered: