tweekmonster / impsort.vim

Sort and highlight Python imports in Vim
MIT License
37 stars 6 forks source link

Conflicts with python-mode #13

Closed balta2ar closed 1 year ago

balta2ar commented 8 years ago

Hello. I've noticed that if I have https://github.com/klen/python-mode in my configuration, impsort does not highlight imports. Could you take a look, please? Thanks!

tweekmonster commented 8 years ago

Sorry for the delay. I haven't used python-mode in a long time, so it may be a little while before I take a close look at this. Did you happen to find any particular cause since you opened this issue?

balta2ar commented 8 years ago

No, not yet. In my set up impsort has no visual effect, unfortunately.

balta2ar commented 7 years ago

Several different vim plugins have been updated since then and now I'm seeing something else. Without python-mode it's still has no visual effect. With python-mode it has, but here is what I've got in :messages after opening .py file:

[impsort] Traceback (most recent call last):
[impsort]   File "/home/ybochkarev/.cache/dein/.cache/init.vim/.dein/bin/imports.py", line 47, in <module>
[impsort]     get_names(sys.argv[1], source)
[impsort]   File "/home/ybochkarev/.cache/dein/.cache/init.vim/.dein/bin/imports.py", line 35, in get_names
[impsort]     print('%s,%s' % (c.name, c.type))
[impsort]   File "/home/ybochkarev/.cache/dein/.cache/init.vim/.dein/bin/jedi/jedi/api/classes.py", line 470, in type
[impsort] 
[impsort]     followed = self.follow_definition()
[impsort]   File "/home/ybochkarev/.cache/dein/.cache/init.vim/.dein/bin/jedi/jedi/evaluate/cache.py", line 41, in wrapper
[impsort]     rv = function(obj, *args, **kwargs)
[impsort]   File "/home/ybochkarev/.cache/dein/.cache/init.vim/.dein/bin/jedi/jedi/api/classes.py", line 498, in follow_definition
[impsort]     defs = self._follow_statements_imports()
[impsort]   File "/home/ybochkarev/.cache/dein/.cache/init.vim/.dein/bin/jedi/jedi/evaluate/cache.py", line 41, in wrapper
[impsort]     rv = function(obj, *args, **kwargs)
[impsort]   File "/home/ybochkarev/.cache/dein/.cache/init.vim/.dein/bin/jedi/jedi/api/classes.py", line 485, in _follow_statements_imports
[impsort]     return i.follow()
[impsort]   File "/home/ybochkarev/.cache/dein/.cache/init.vim/.dein/bin/jedi/jedi/evaluate/cache.py", line 41, in wrapper
[impsort]     rv = function(obj, *args, **kwargs)
[impsort]   File "/home/ybochkarev/.cache/dein/.cache/init.vim/.dein/bin/jedi/jedi/evaluate/imports.py", line 103, in follow
[impsort]     for t in types))
[impsort]   File "/home/ybochkarev/.cache/dein/.cache/init.vim/.dein/bin/jedi/jedi/evaluate/imports.py", line 103, in <genexpr>
[impsort]     for t in types))
[impsort]   File "/home/ybochkarev/.cache/dein/.cache/init.vim/.dein/bin/jedi/jedi/evaluate/__init__.py", line 117, in find_types
[impsort]     scopes = f.scopes(search_global)
[impsort]   File "/home/ybochkarev/.cache/dein/.cache/init.vim/.dein/bin/jedi/jedi/evaluate/finder.py", line 109, in scopes
[impsort]     return ((n, None) for n in self.scope.names_dicts(search_global))
[impsort] AttributeError: 'NoneType' object has no attribute 'names_dicts'
[impsort] 
Press ENTER or type command to continue

And it looks as follows (not everything is colored):

As for the version, I've updated all the plugins today (including dein, python-mode and impsort). NVIM v0.2.0-1-g9956bee.

@tweekmonster IMHO, the stack trace suggests that it may be an issue in jedi. It seems that you're using 0.9.0 while 0.10.0 is out. Maybe upgrading could help.

tweekmonster commented 7 years ago

@balta2ar I vaguely remember that error. I think it's raised when Jedi is having problems with decorators. Do you know if you have an incomplete decorated function somewhere? For example:

@decorator
def func():

Note it doesn't have a function body. I can upgrade the submodule since it doesn't seem to hurt anything, but I'm not sure if there's been a fix for this issue yet.

balta2ar commented 7 years ago

@tweekmonster No, 0.10.0 did not help. Also, I don't think there are decorated functions without a body in the code I'm working with. I reported the issue to jedi, I'll post updates here if there are any news.

balta2ar commented 7 years ago

As I mentioned here, it looks like this has been fixed in jedi. Maybe it's better to wait for an actual jedi release, and only after that update submodule and close this issue.