Skip to content

Repository files navigation

PythonTA VS Code Extension

This project is an extension for running PythonTA within VS Code.

Developers

Requirements

  1. VS Code
  2. Python extension for VS Code
  3. uv
  4. Node.js
  5. pnpm

Setup

  1. Install the extension's dependencies into the bundled libraries directory:
    uv pip install --target bundled/libs -r pyproject.toml
  2. Install Javascript dependencies: pnpm install.

Testing the Extension Locally

  1. To start the extension, use the Debug Extension and Python (shortcut F5) configuration in VS Code.
  2. In the new VS Code window that appears, open a folder containing Python files, or create a new file.
  3. Open a file with a snippet or write a snippet of Python code that violates standard PythonTA rule. For example:
    def add_numbers(a, b):
        return a + c
  4. Save the file, and look for the diagnostic messages and rule codes generated by PythonTA.
  5. You can view the extension output under the Output tab, and select "PythonTA VS Code Extension"

Troubleshooting: Server Crashes on File Reload

If you are actively testing the extension using the debugger (F5), you may notice that closing and reopening a Python file causes the server to crash repeatedly with a ConnectionRefusedError.

This is expected behavior in the development environment and will not happen in the published extension. It occurs because the VS Code Extension Development Host wraps the language server in a debugpy instance that fails to cleanly release its port when the file reloads.

If you want to avoid this during testing, and you do not need breakpoints, launch the Extension Development Host using Debug Extension Only (via the dropdown in the Run and Debug menu) instead of F5.

Running tests

To run the Python tests, run uv run pytest src/test/python_tests.

Linting

To lint the Typescript code, run pnpm run lint.

Linting for the Python code has not been set up yet.

Template information

This repository is based on a Template for VS Code python tools extensions. See the template README.md for more information.

About

VSCode extension for running PythonTA

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages