News

Python in VS Code Does Browser-Based Editing via 'github.dev' Trick

New functionality to quickly launch Visual Studio Code in the browser is being infused into more dev tooling, including the Python extension that uses the Pylance language server for language-specific intelligence.

The new capability surprised hundreds of developers recently ("One-Click VS Code in Browser from GitHub Repo ('How Did I Not Know This?')") when GitHub introduced the github.dev feature in preview, providing the ability to instantly open up VS Code in a browser in order to edit the source code found in any repository (and you just got a taste of the experience if you clicked on that github.dev link). That's done simply by pressing the period (.) key to bring up the browser-based VS Code environment from any repo, or changing the URL from "github.com" to "github.dev." The capability is part of GitHub Codespaces, basically a cloud-hosted VS Code environment, but it was only announced recently via social media posts.

"It's a quick way to edit and navigate code," says GitHub, which is owned by Microsoft. "It's especially useful if you want to edit multiple files at a time or take advantage of all the powerful code editing features of Visual Studio Code when making a quick change."

Web-Based Editor in Animated Action
[Click on image for larger, animated GIF view.] Web-Based Editor in Animated Action (source: GitHub).

Documentation says the web-based editor provides many of the benefits of VS Code, including search, syntax highlighting and a source control view.

Syntax highlighting in Python code -- along with other language-specific "smartness" -- is provided in Microsoft's Python extension for VS Code via the Pylance language server, and that's where the new functionality is brought into play in the August 2021 update to the hugely popular Python extension.

"We are delighted to announce that as of this release you can enjoy the performant editing experience of Pylance in the browser via github.dev," said Savannah Ostrowski, a program manager for Pylance and Python in Visual Studio, in a Sept. 2 blog post. "If you are unfamiliar with github.dev, you can head over to any repo, pull request, or file on GitHub and hit '.' on your keyboard (or change the URL to github.dev) to give it a shot!"

Support for core editing features when exploring a new codebase or making minor edits to Python code include:

Ostrowski said one issue with the feature is that developers can't yet run Python code in the browser, but "you can do so in a Jupyter notebook with the vscode-pyolite extension (in preview), made by one of our team members!"

Developers can provide feedback on the new github.dev feature in the Pylance issue tracker.

Other highlights of the update include:

  • Revamped testing interface: By leveraging the built-in test explorer in VS Code, the team crossed off 55 GitHub repo issues with an overhaul of the testing UI touching on test discovery, navigation, configuration, and running and debugging tests.
  • New button for running and debugging files on the editor: Now, when pressing the editor's Run button, developers will see debugging files as an option. Choosing that option will run the active Python file in the terminal by default, but debugging is also an option developers can take with a couple quick clicks.
    Run and Debug in Animated Action
    [Click on image for larger, animated GIF view.] Run and Debug in Animated Action (source: Microsoft).
  • Microsoft Python Language Server end of life November 2021: After Pylance was made the default language server for Python in VS Code back in May, Ostrowski said it's now being used by nearly all coders. After deprecation is finalized in November, the legacy Microsoft Python Language Server repository will be archived, though developers will still be able to fork and build upon its codebase.
  • Limited IntelliSense support for Python 2.7 starting in October 2021: "Starting with the 2021.10 of the Python extension, we will only offer support for Jedi 0.18 and higher, and no longer ship support for Jedi 0.17. We will also be removing support for ctags and rope at the same time."

The Python extension in the VS Code marketplace is by far the most popular tool available for Microsoft's open source-based, cross-platform code editor. As of this writing, it has been installed some 41.6 million times while the No. 2 offering, C/C++, shows fewer than 23 million downloads. Pylance comes bundled with the Python tool as an optional dependency, along with the Jupyter extension.

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