This project is an extension for running PythonTA within VS Code.
- Install the extension's dependencies into the bundled libraries directory:
uv pip install --target bundled/libs -r pyproject.toml
- Install Javascript dependencies:
pnpm install.
- To start the extension, use the
Debug Extension and Python(shortcutF5) configuration in VS Code. - In the new VS Code window that appears, open a folder containing Python files, or create a new file.
- 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
- Save the file, and look for the diagnostic messages and rule codes generated by PythonTA.
- You can view the extension output under the Output tab, and select "PythonTA VS Code Extension"
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.
To run the Python tests, run uv run pytest src/test/python_tests.
To lint the Typescript code, run pnpm run lint.
Linting for the Python code has not been set up yet.
This repository is based on a Template for VS Code python tools extensions. See the template README.md for more information.