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 for Converge360.

comments powered by Disqus

Featured

  • Move Over, Stack Overflow: Microsoft Launches Q&A for .NET

    Stack Overflow probably isn't worried, but Microsoft has launched its own Q&A site for all things .NET, seeking to provide a one-stop-shop for getting .NET technical questions answered by the community.

  • Developer Decries WinForms-to-Blazor Performance Degradation

    Since shipping .NET 5, Visual Studio 2019 v16.8 and more goodies recently, Microsoft has been touting speed improvements in many components -- including the red-hot Blazor project -- but some real-world developers are finding different results.

  • Google Cloud Functions Supports .NET Core 3.1 (but not .NET 5)

    Google Cloud Functions -- often used for serverless, event-driven projects -- now supports .NET, but the new support is a release behind Microsoft's latest .NET offering.

  • Binary Classification Using PyTorch: Model Accuracy

    In the final article of a four-part series on binary classification using PyTorch, Dr. James McCaffrey of Microsoft Research shows how to evaluate the accuracy of a trained model, save a model to file, and use a model to make predictions.

  • Visual Basic in .NET 5: Ready for WinForms Apps

    With the milestone .NET 5 and Visual Studio 2019 v16.8 releases now out, Microsoft is reminding Visual Basic coders that their favorite programming language enjoys full support and the troublesome Windows Forms Designer is even complete -- almost.

Upcoming Events