Skip to content

Use stdin for PythonTA document linting - #26

Merged
david-yz-liu merged 4 commits into
pyta-uoft:mainfrom
PraneethS42:feature/stdin-linting
Oct 8, 2026
Merged

david-yz-liu merged 4 commits into
pyta-uoft:mainfrom
PraneethS42:feature/stdin-linting

Conversation

@PraneethS42

@PraneethS42 PraneethS42 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Proposed Changes

This PR updates the language server to lint the contents supplied by VS Code through standard input instead of rereading the saved file from disk.

Using document.source ensures PythonTA analyzes the document content known to the language server. PythonTA 2.13.1 introduced the required --stdin support.

Language server changes

  • bundled/tool/lsp_server.py
    • Enables stdin mode from _linting_helper
    • Passes --stdin to PythonTA instead of the document filename
    • When stdin mode is disabled, continues support of filename-based execution
    • Handles PythonTA’s temporary stdin_*.py URI. Since each stdin invocation analyzes one document, the server extracts diagnostics from that result and republishes them using the actual VS Code document URI
  • bundled/tool/lsp_jsonrpc.py
    • Ensures empty document contents ("") are forwarded when PythonTA runs through the alternate-interpreter JSON-RPC path
    • Previously, empty strings were treated as missing values and omitted from the RPC message

Dependency changes

  • pyproject.toml
    • As per discussion, replaces the moving/unstable PythonTA dependency with the stable python-ta==2.13.1 release, which includes stdin support
  • uv.lock
    • Regenerated with uv sync to lock PythonTA 2.13.1 and its package metadata

Test changes

  • src/test/python_tests/test_server.py
    • Adds an end-to-end test where the editor content differs from the file on disk. Confirms diagnostics correspond to document.source: proves PythonTA reads from stdin
  • src/test/python_tests/test_lsp_server_helpers.py
    • Adds unit coverage for PythonTA output containing a temporary stdin URI. Confirms diagnostics are still returned for publication against the real document.
  • src/test/python_tests/test_lsp_jsonrpc.py
    • Adds coverage ensuring an empty source string is preserved in JSON-RPC messages
  • src/test/python_tests/test_notebook.py
    • Updates the notebook-close test to wait specifically for the empty diagnostic notification.
    • This prevents a delayed notebook-open diagnostic notification from ending the test prematurely now that notebook contents are successfully linted through stdin.
Screenshots of your changes (if applicable)

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
✨ New feature (non-breaking change that adds functionality) X
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency) x
📖 Documentation update (change that updates documentation)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.
  • I have updated the project Changelog (this is required for all changes).

After opening your pull request:

  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

(Include any questions or comments you have regarding your changes.)

@coveralls

coveralls commented Sep 30, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 37417097920

Coverage decreased (-15.0%) to 62.402%

Details

  • Coverage decreased (-15.0%) from the base build.
  • Patch coverage: 4 uncovered changes across 1 file (12 of 16 lines covered, 75.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
bundled/tool/lsp_server.py 15 11 73.33%
Total (2 files) 16 12 75.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1293
Covered Lines: 805
Line Coverage: 62.26%
Relevant Branches: 106
Covered Branches: 68
Branch Coverage: 64.15%
Branches in Coverage %: Yes
Coverage Strength: 1.19 hits per line

💛 - Coveralls

@PraneethS42 PraneethS42 changed the title Added stdin linting support Use stdin for PythonTA document linting Sep 30, 2026

@david-yz-liu david-yz-liu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PraneethS42, the changes look okay to me, but I don't think this is working properly. When I run this with the example in the README, here's what I see (after expanding the error):

Image

This is not the expected error message, and seems to indicate that some junk characters are being sent to PythonTA.

@PraneethS42

Copy link
Copy Markdown
Contributor Author

That's interesting, I'll take a look at this shortly. When I was testing, I was running it on some other personal Python files as opposed to the README example. I'll make sure to test that first in the future.

@PraneethS42

Copy link
Copy Markdown
Contributor Author

Could you take another look and see if it's working on your system as intended?

@david-yz-liu david-yz-liu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great, thanks @PraneethS42!

@david-yz-liu
david-yz-liu merged commit ea28131 into pyta-uoft:main Oct 8, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants