Friday, October 14, 2016

PyDev 5.3.0 (Code completion improvements, Validate code with Python 2 & 3 while typing, PyQt5 event loop in interactive console)

PyDev 5.3.0 is now available for download.

The major focus in this release was in the code completion, with a number of enhancements...

The main one is that it's now possible to request completions by matching a substring of the requested name, not only on the first chars (to make use of it, it has to be enabled in Preferences > PyDev > Editor > Code Completion > Match substrings on code completion).

Now, after this change was implemented, I noted that it was hard to use it by itself because as more completions are brought for a name it was hard to actually reach the one you wanted, so, it triggered to have even more improvements to the code completion, especially in the sorting, so, now completions in PyDev are re-sorted when typing so that based on the current name typed the matches that are exact matches or start with the requested token appear first, then as a second heuristic, the type of the completion is taken into account (i.e.: parameters appear before context-insensitive completions) and at last, where the completion was found plays a role, so that completions which are from the current project appear before referenced projects (which in turn appear before the standard library modules).

Also, the completions now take advantage of styling, so, the part of the completion which was matched is now shown in bold and the part of the completion which shows a qualifier for the completion is also properly styled.

All in all, I'm really enjoying using this new code completion mode, and will probably make it the default in the next release.

Besides this, the apply mode when holding Ctrl and Shift changed a bit... Ctrl on apply now always means only "replace current name with completion" and Shift (when focusing the completion pop-up) means "do local import" on completions with auto-import (it's important to note that the focus on the pop-up is important as Shift+Enter on the editor already has an important role as it cancels the completion and moves the cursor to a new line) .

Other niceties of this release include the possibility of specifying that a project should be checked with a Python 2 and a Python 3 grammar (customized in Project Properties > PyDev - Interpreter/Grammar > grammars for "additional syntax validation") and the interactive console now supports PyQt5 for interactively inspecting a widget while using the console (i.e.: it frees the event loop to process events in the interactive console as it already did for Gtk, PySide, PyQt4, etc). It may be activated with %matplotlib qt5 (when using IPython/matplotlib) or in Preferences > PyDev > Interactive Console > Enable GUI event loop integration > PyQt5.

Enjoy ;)


Dinh said...

I upgraded Python to 5.3.0 and found that code completion didn't work.

(org/python/pydev/editor/codecompletion/PyLinkedModeCompletionProposal is always displayed instead of real suggestions)

Dinh said...

Got it. Pydev 5.3.0 does not work with Eclipse Mars. I upgraded Eclipse to Neon and it worked.

Ben Jao Ming said...

Awesome work!! :)