Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: Complete base class methods for Python

Is it possible to make either jedi.el or anaconda-mode complete base class methods? For example, when subclassing html.parser.HTMLParser I expect it to complete the following code at point (1) (base class has methods like handle_data or handle_starttag):

import html.parser
class MyParser(html.parser.HTMLParser):
    def handle_  # (1)
like image 414
nightuser Avatar asked Oct 29 '22 14:10

nightuser


1 Answers

I've done some research on this issue and I've found that it is implemented in the latest version of jedi (0.10.0). Unfortunately, this version is in development state right now and is not available from pip. However, many editors use 0.10.0: Atom, VsCode, and even jedi-vim from the author of jedi.

It's easy to update jedi's version in anaconda-mode: https://github.com/nightuser/anaconda-mode. The actual change is just a one line. The Python part of anaconda-mode must be reinstalled -- simply delete anaconda-mode directory. The default location is ~/.emacs.d/anaconda-mode for Emacs and ~/.emacs.d/.cache/anaconda-mode for Spacemacs.

upd: It seems that 0.10.0 will be released soon: https://github.com/davidhalter/jedi/issues/740 .

upd2: It was released and know everything works out of the box. Just remove anaconda-mode directory and it'll automatically install latest version.

like image 121
nightuser Avatar answered Nov 15 '22 07:11

nightuser