Conversation
- Provide completions for incomplete test/fixture signatures using text-based heuristics when AST parsing fails (e.g. open paren, missing colon/body) - Support multiline, trailing newline, and signatures without parens - Handle usefixtures/pytestmark decorators with open paren - Add extensive tests for all fallback scenarios - Expand completion trigger characters to include ( and ,
Prevents a fixture from being suggested as a parameter to itself in completion lists. Updates filtering logic and tests to handle current fixture context.
When completion is triggered by a comma, insert a space before the fixture name so that "fixture1," becomes "fixture1, fixture2". Update completion helpers and tests to support insert prefix.
- Scan decorator lines individually for scope= to avoid quadratic string ops - Refactor completion filtering to use CompletionOpts struct for clarity - Improve edge case handling in completion context detection - Clarify scan limits and fallback behavior in resolver comments
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #96 +/- ##
==========================================
+ Coverage 61.25% 63.17% +1.92%
==========================================
Files 26 26
Lines 3198 3392 +194
==========================================
+ Hits 1959 2143 +184
- Misses 1239 1249 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR improves pytest-language-server completion UX by expanding completion trigger characters, refining fixture suggestions (e.g., exclude the currently edited fixture), and adding a text-based completion-context fallback for syntactically incomplete Python.
Changes:
- Expanded LSP completion trigger characters to include
(and,in addition to"and added comma-trigger insertion spacing. - Added per-request completion options to exclude the current fixture from suggestions and to apply an insert-text prefix.
- Implemented AST-based signature end detection plus a text-based fallback for incomplete/invalid Python, with extensive new tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/main.rs |
Expands CompletionOptions.trigger_characters to trigger completion on " / ( / ,. |
src/providers/completion.rs |
Adds CompletionOpts to control scope filtering, self-exclusion, and comma-trigger spacing; updates completion builders and tests. |
src/fixtures/resolver.rs |
Adds AST-based signature-end detection and a text fallback for completion context when parsing fails. |
tests/test_fixtures.rs |
Adds many new tests covering signature/body context detection and text fallback scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@benediktziegler can you check copilot's reviews comments? |
test: add tests for completion context text fallback edge cases
|
Fixed the comments. |
This pull request updates the language server's completion trigger behavior to improve the developer experience. The main change is the expansion of the set of characters that will trigger code completion suggestions.
Enhancements to code completion triggers:
trigger_charactersin the language server'sCompletionOptionsto include"("and","in addition to", so that code completion is now triggered when the user types a quote, parenthesis, or comma.