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

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube