News

VS Code Gets AI-Assisted IntelliCode for Python

Python developers using Visual Studio Code are getting an AI-assisted boost from the editor's IntelliCode extension.

IntelliCode leverages machine learning algorithms to provide AI-assisted coding tips that go beyond regular IntelliSense code-completion hints. Its machine learning model is trained on more than 2,000 Python project repos, letting IntelliCode infer the correct code-completion suggestions from the context in which the code is being typed.

By using this advanced inference capability, IntelliCode predicts what a programmer is aiming for as a line of code is typed in, presenting the most likely code-completion options in the top its suggestion list, marked by stars. Previously, with IntelliSense, a wide range of options would be presented, requiring manual winnowing down to find the desired choice.

Python IntelliCode in Animated Action
[Click on image for larger, animated view.] Python IntelliCode in Animated Action (source: Microsoft).

Now, when a programmer types in a variable, the list of suggestions changes depending on the surrounding code.

"When writing Python code, the IntelliSense code completion speeds up your productivity by providing suggestions as you type," a July 24 Visual Studio blog post said. "However, there can be hundreds of completions to scroll through, and you typically need to type the first few characters out before you can get close to the right result. Using our machine learning algorithm, IntelliCode can infer the most relevant completions based on the current code context."

Using the new AI-assisted technology requires installation of the Visual Studio IntelliCode - Preview extension and the wildly popular (more than 15 million installs) Python extension. After those are installed, IntelliCode will download the latest machine learning model to provide the most relevant suggestions.

The tools rely upon the Microsoft Python Language Server, also in preview, that provides the programming language "smarts" to IDEs and code editors for advanced IntelliSense/IntelliCode functionality.

The language server allowed Microsoft to extract the highly touted Python IntelliSense from its flagship Visual Studio IDE and make it a portable, standalone product, recently bundled into the VS Code Python extension.

It provides benefits such as:

  • Syntax errors as you type in code
  • Warnings when modules are not found
  • Using Typeshed files to fill in missing completions for modules
  • Improved performance for analyzing your workspace and presenting completions
  • Ability to detect syntax errors on your entire workspace, rather than just the current file
  • Faster startup times
  • Faster imports
  • Better handling for a number of language constructs

"IntelliCode will prompt you to enable the Microsoft Python Language server, so you’ll also notice that you get enhanced IntelliSense with syntax errors and basic warnings will now appear as you type, said Dan Taylor, Senior Program Manager, Python Developer Tools, in the post. "IntelliSense, combined with the new Python Language Server, is also richer: the language server uses open source typeshed definitions to provide completions for types where they can’t be statically inferred.

"The combination of both the new Python extension features and IntelliCode will make you more productive when writing everyday Python code."

The Visual Studio IntelliCode preview extension, which only pertains to the July release of VS Code, has been installed 2,355 times at the time of this writing, earning a perfect 5.0 rating from three reviewers. More information on the new offering is available in a July 24 Channel 9 video.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

Subscribe on YouTube