pytest-language-server 0.6.0__py3-none-macosx_10_12_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,433 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytest-language-server
3
+ Version: 0.6.0
4
+ Classifier: Development Status :: 4 - Beta
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Programming Language :: Rust
14
+ Classifier: Topic :: Software Development :: Testing
15
+ Classifier: Topic :: Software Development :: Libraries
16
+ License-File: LICENSE
17
+ Summary: A blazingly fast Language Server Protocol implementation for pytest
18
+ Keywords: pytest,lsp,language-server,testing
19
+ Author-email: Thiago Bellini Ribeiro <hackedbellini@gmail.com>
20
+ License: MIT
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
23
+ Project-URL: Homepage, https://github.com/bellini666/pytest-language-server
24
+ Project-URL: Repository, https://github.com/bellini666/pytest-language-server
25
+ Project-URL: Issues, https://github.com/bellini666/pytest-language-server/issues
26
+
27
+ # pytest-language-server 🔥
28
+
29
+ [![CI](https://github.com/bellini666/pytest-language-server/workflows/CI/badge.svg)](https://github.com/bellini666/pytest-language-server/actions/workflows/ci.yml)
30
+ [![Security Audit](https://github.com/bellini666/pytest-language-server/workflows/Security%20Audit/badge.svg)](https://github.com/bellini666/pytest-language-server/actions/workflows/security.yml)
31
+ [![PyPI version](https://badge.fury.io/py/pytest-language-server.svg)](https://badge.fury.io/py/pytest-language-server)
32
+ [![Downloads](https://static.pepy.tech/badge/pytest-language-server)](https://pepy.tech/project/pytest-language-server)
33
+ [![Crates.io](https://img.shields.io/crates/v/pytest-language-server.svg)](https://crates.io/crates/pytest-language-server)
34
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
35
+ [![Python Version](https://img.shields.io/pypi/pyversions/pytest-language-server.svg)](https://pypi.org/project/pytest-language-server/)
36
+
37
+ > **Shamelessly vibed into existence** 🤖✨
38
+ >
39
+ > This entire LSP implementation was built from scratch in a single AI-assisted coding session.
40
+ > No template. No boilerplate. Just pure vibes and Rust. That's right - a complete, working
41
+ > Language Server Protocol implementation for pytest, vibed into reality through the power of
42
+ > modern AI tooling. Even this message about vibing was vibed into existence.
43
+
44
+ A blazingly fast Language Server Protocol (LSP) implementation for pytest, built with Rust.
45
+
46
+ ## Demo
47
+
48
+ ![pytest-language-server demo](demo.gif)
49
+
50
+ *Showcasing go-to-definition, code completion, hover documentation, and code actions. Demo also vibed into existence.* ✨
51
+
52
+ ## Features
53
+
54
+ ### 🎯 Go to Definition
55
+ Jump directly to fixture definitions from anywhere they're used:
56
+ - Local fixtures in the same file
57
+ - Fixtures in `conftest.py` files
58
+ - Third-party fixtures from pytest plugins (pytest-mock, pytest-asyncio, etc.)
59
+ - Respects pytest's fixture shadowing/priority rules
60
+
61
+ ### ✨ Code Completion
62
+ Smart auto-completion for pytest fixtures:
63
+ - **Context-aware**: Only triggers inside test functions and fixture functions
64
+ - **Hierarchy-respecting**: Suggests fixtures based on pytest's priority rules (same file > conftest.py > third-party)
65
+ - **Rich information**: Shows fixture source file and docstring
66
+ - **No duplicates**: Automatically filters out shadowed fixtures
67
+ - **Works everywhere**: Completions available in both function parameters and function bodies
68
+ - Supports both sync and async functions
69
+
70
+ ### 🔍 Find References
71
+ Find all usages of a fixture across your entire test suite:
72
+ - Works from fixture definitions or usage sites
73
+ - Character-position aware (distinguishes between fixture name and parameters)
74
+ - Shows references in all test files
75
+ - Correctly handles fixture overriding and hierarchies
76
+ - **LSP spec compliant**: Always includes the current position in results
77
+
78
+ ### 📚 Hover Documentation
79
+ View fixture information on hover:
80
+ - Fixture signature
81
+ - Source file location
82
+ - Docstring (with proper formatting and dedenting)
83
+ - Markdown support in docstrings
84
+
85
+ ### 💡 Code Actions (Quick Fixes)
86
+ One-click fixes for common pytest issues:
87
+ - **Add missing fixture parameters**: Automatically add undeclared fixtures to function signatures
88
+ - **Smart insertion**: Handles both empty and existing parameter lists
89
+ - **Editor integration**: Works with any LSP-compatible editor's quick fix menu
90
+ - **LSP compliant**: Full support for `CodeActionKind::QUICKFIX`
91
+
92
+ ### ⚠️ Diagnostics & Quick Fixes
93
+ Detect and fix common pytest fixture issues with intelligent code actions:
94
+
95
+ **Undeclared Fixture Detection:**
96
+ - Detects when fixtures are used in function bodies but not declared as parameters
97
+ - **Line-aware scoping**: Correctly handles local variables assigned later in the function
98
+ - **Hierarchy-aware**: Only reports fixtures that are actually available in the current file's scope
99
+ - **Works in tests and fixtures**: Detects undeclared usage in both test functions and fixture functions
100
+ - Excludes built-in names (`self`, `request`) and actual local variables
101
+
102
+ **One-Click Quick Fixes:**
103
+ - **Code actions** to automatically add missing fixture parameters
104
+ - Intelligent parameter insertion (handles both empty and existing parameter lists)
105
+ - Works with both single-line and multi-line function signatures
106
+ - Triggered directly from diagnostic warnings
107
+
108
+ Example:
109
+ ```python
110
+ @pytest.fixture
111
+ def user_db():
112
+ return Database()
113
+
114
+ def test_user(user_db): # ✅ user_db properly declared
115
+ user = user_db.get_user(1)
116
+ assert user.name == "Alice"
117
+
118
+ def test_broken(): # ⚠️ Warning: 'user_db' used but not declared
119
+ user = user_db.get_user(1) # 💡 Quick fix: Add 'user_db' fixture parameter
120
+ assert user.name == "Alice"
121
+ ```
122
+
123
+ **How to use quick fixes:**
124
+ 1. Place cursor on the warning squiggle
125
+ 2. Trigger code actions menu (usually Cmd+. or Ctrl+. in most editors)
126
+ 3. Select "Add 'fixture_name' fixture parameter"
127
+ 4. The parameter is automatically added to your function signature
128
+
129
+ ### ⚡️ Performance
130
+ Built with Rust for maximum performance:
131
+ - Fast workspace scanning with concurrent file processing
132
+ - Efficient AST parsing using rustpython-parser
133
+ - Lock-free data structures with DashMap
134
+ - Minimal memory footprint
135
+
136
+ ## Installation
137
+
138
+ Choose your preferred installation method:
139
+
140
+ ### 📦 PyPI (Recommended)
141
+
142
+ The easiest way to install for Python projects:
143
+
144
+ ```bash
145
+ # Using uv (recommended)
146
+ uv tool install pytest-language-server
147
+
148
+ # Or with pip
149
+ pip install pytest-language-server
150
+
151
+ # Or with pipx (isolated environment)
152
+ pipx install pytest-language-server
153
+ ```
154
+
155
+ ### 🍺 Homebrew (macOS/Linux)
156
+
157
+ Install via Homebrew for system-wide availability:
158
+
159
+ ```bash
160
+ brew install bellini666/tap/pytest-language-server
161
+ ```
162
+
163
+ To add the tap first:
164
+ ```bash
165
+ brew tap bellini666/tap https://github.com/bellini666/pytest-language-server
166
+ brew install pytest-language-server
167
+ ```
168
+
169
+ ### 🦀 Cargo (Rust)
170
+
171
+ Install from crates.io if you have Rust installed:
172
+
173
+ ```bash
174
+ cargo install pytest-language-server
175
+ ```
176
+
177
+ ### 📥 Pre-built Binaries
178
+
179
+ Download pre-built binaries from the [GitHub Releases](https://github.com/bellini666/pytest-language-server/releases) page.
180
+
181
+ Available for:
182
+ - **Linux**: x86_64, aarch64, armv7 (glibc and musl)
183
+ - **macOS**: Intel and Apple Silicon
184
+ - **Windows**: x64 and x86
185
+
186
+ ### 🔨 From Source
187
+
188
+ Build from source for development or customization:
189
+
190
+ ```bash
191
+ git clone https://github.com/bellini666/pytest-language-server
192
+ cd pytest-language-server
193
+ cargo build --release
194
+ ```
195
+
196
+ The binary will be at `target/release/pytest-language-server`.
197
+
198
+ ## Setup
199
+
200
+ ### Neovim (with nvim-lspconfig)
201
+
202
+ ```lua
203
+ require'lspconfig'.pytest_lsp.setup{
204
+ cmd = { "pytest-language-server" },
205
+ filetypes = { "python" },
206
+ root_dir = function(fname)
207
+ return require'lspconfig'.util.root_pattern('pyproject.toml', 'setup.py', 'setup.cfg', 'pytest.ini')(fname)
208
+ end,
209
+ }
210
+ ```
211
+
212
+ ### Zed
213
+
214
+ Install the extension from the extensions marketplace:
215
+
216
+ 1. Open Zed
217
+ 2. Open the command palette (Cmd+Shift+P / Ctrl+Shift+P)
218
+ 3. Search for "zed: extensions"
219
+ 4. Search for "pytest Language Server"
220
+ 5. Click "Install"
221
+
222
+ The extension will automatically detect `pytest-language-server` if it's in your PATH.
223
+
224
+ ### VS Code
225
+
226
+ Install the extension from the marketplace (coming soon) or configure manually:
227
+
228
+ ```json
229
+ {
230
+ "pytest-language-server.enable": true,
231
+ "pytest-language-server.path": "pytest-language-server"
232
+ }
233
+ ```
234
+
235
+ ### Other Editors
236
+
237
+ Any editor with LSP support can use pytest-language-server. Configure it to run the `pytest-language-server` command.
238
+
239
+ ## Configuration
240
+
241
+ ### Logging
242
+
243
+ Control log verbosity with the `RUST_LOG` environment variable:
244
+
245
+ ```bash
246
+ # Minimal logging (default)
247
+ RUST_LOG=warn pytest-language-server
248
+
249
+ # Info level
250
+ RUST_LOG=info pytest-language-server
251
+
252
+ # Debug level (verbose)
253
+ RUST_LOG=debug pytest-language-server
254
+
255
+ # Trace level (very verbose)
256
+ RUST_LOG=trace pytest-language-server
257
+ ```
258
+
259
+ Logs are written to stderr, so they won't interfere with LSP communication.
260
+
261
+ ### Virtual Environment Detection
262
+
263
+ The server automatically detects your Python virtual environment:
264
+ 1. Checks for `.venv/`, `venv/`, or `env/` in your project root
265
+ 2. Falls back to `$VIRTUAL_ENV` environment variable
266
+ 3. Scans third-party pytest plugins for fixtures
267
+
268
+ ### Code Actions / Quick Fixes
269
+
270
+ Code actions are automatically available on diagnostic warnings. If code actions don't appear in your editor:
271
+
272
+ 1. **Check LSP capabilities**: Ensure your editor supports code actions (most modern editors do)
273
+ 2. **Enable debug logging**: Use `RUST_LOG=info` to see if actions are being created
274
+ 3. **Verify diagnostics**: Code actions only appear where there are warnings
275
+ 4. **Trigger manually**: Use your editor's code action keybinding (Cmd+. / Ctrl+.)
276
+
277
+ For detailed troubleshooting, see [CODE_ACTION_TESTING.md](CODE_ACTION_TESTING.md).
278
+
279
+ ## Supported Fixture Patterns
280
+
281
+ ### Decorator Style
282
+ ```python
283
+ @pytest.fixture
284
+ def my_fixture():
285
+ """Fixture docstring."""
286
+ return 42
287
+ ```
288
+
289
+ ### Assignment Style (pytest-mock)
290
+ ```python
291
+ mocker = pytest.fixture()(_mocker)
292
+ ```
293
+
294
+ ### Async Fixtures
295
+ ```python
296
+ @pytest.fixture
297
+ async def async_fixture():
298
+ return await some_async_operation()
299
+ ```
300
+
301
+ ### Fixture Dependencies
302
+ ```python
303
+ @pytest.fixture
304
+ def fixture_a():
305
+ return "a"
306
+
307
+ @pytest.fixture
308
+ def fixture_b(fixture_a): # Go to definition works on fixture_a
309
+ return fixture_a + "b"
310
+ ```
311
+
312
+ ## Fixture Priority Rules
313
+
314
+ pytest-language-server correctly implements pytest's fixture shadowing rules:
315
+ 1. **Same file**: Fixtures defined in the same file have highest priority
316
+ 2. **Closest conftest.py**: Searches parent directories for conftest.py files
317
+ 3. **Virtual environment**: Third-party plugin fixtures
318
+
319
+ ### Fixture Overriding
320
+
321
+ The LSP correctly handles complex fixture overriding scenarios:
322
+
323
+ ```python
324
+ # conftest.py (parent)
325
+ @pytest.fixture
326
+ def cli_runner():
327
+ return "parent runner"
328
+
329
+ # tests/conftest.py (child)
330
+ @pytest.fixture
331
+ def cli_runner(cli_runner): # Overrides parent
332
+ return cli_runner # Uses parent
333
+
334
+ # tests/test_example.py
335
+ def test_example(cli_runner): # Uses child
336
+ pass
337
+ ```
338
+
339
+ When using find-references:
340
+ - Clicking on the **function name** `def cli_runner(...)` shows references to the child fixture
341
+ - Clicking on the **parameter** `cli_runner(cli_runner)` shows references to the parent fixture
342
+ - Character-position aware to distinguish between the two
343
+
344
+ ## Supported Third-Party Fixtures
345
+
346
+ Automatically discovers fixtures from popular pytest plugins:
347
+ - **pytest-mock**: `mocker`, `class_mocker`
348
+ - **pytest-asyncio**: `event_loop`
349
+ - **pytest-django**: Database fixtures
350
+ - **pytest-cov**: Coverage fixtures
351
+ - And any other pytest plugin in your environment
352
+
353
+ ## Architecture
354
+
355
+ - **Language**: Rust 🦀
356
+ - **LSP Framework**: tower-lsp
357
+ - **Parser**: rustpython-parser
358
+ - **Concurrency**: tokio async runtime
359
+ - **Data Structures**: DashMap for lock-free concurrent access
360
+
361
+ ## Development
362
+
363
+ ### Prerequisites
364
+
365
+ - Rust 1.83+ (2021 edition)
366
+ - Python 3.10+ (for testing)
367
+
368
+ ### Building
369
+
370
+ ```bash
371
+ cargo build --release
372
+ ```
373
+
374
+ ### Running Tests
375
+
376
+ ```bash
377
+ cargo test
378
+ ```
379
+
380
+ ### Logging During Development
381
+
382
+ ```bash
383
+ RUST_LOG=debug cargo run
384
+ ```
385
+
386
+ ## Security
387
+
388
+ Security is a priority. This project includes:
389
+ - Automated dependency vulnerability scanning (cargo-audit)
390
+ - License compliance checking (cargo-deny)
391
+ - Daily security audits in CI/CD
392
+ - Dependency review on pull requests
393
+ - Pre-commit security hooks
394
+
395
+ See [SECURITY.md](SECURITY.md) for our security policy and how to report vulnerabilities.
396
+
397
+ ## Contributing
398
+
399
+ Contributions are welcome! Please feel free to submit a Pull Request.
400
+
401
+ ### Development Setup
402
+
403
+ 1. Install pre-commit hooks:
404
+ ```bash
405
+ pre-commit install
406
+ ```
407
+
408
+ 2. Run security checks locally:
409
+ ```bash
410
+ cargo audit
411
+ cargo clippy
412
+ cargo test
413
+ ```
414
+
415
+ ## License
416
+
417
+ MIT License - see LICENSE file for details.
418
+
419
+ ## Acknowledgments
420
+
421
+ Built with:
422
+ - [tower-lsp](https://github.com/ebkalderon/tower-lsp) - LSP framework
423
+ - [rustpython-parser](https://github.com/RustPython/RustPython) - Python AST parsing
424
+ - [tokio](https://tokio.rs/) - Async runtime
425
+
426
+ Special thanks to the pytest team for creating such an amazing testing framework.
427
+
428
+ ---
429
+
430
+ **Made with ❤️ and Rust. Shamelessly vibed into existence. Blazingly fast. 🔥**
431
+
432
+ *When you need a pytest LSP and the vibes are just right.* ✨
433
+
@@ -0,0 +1,5 @@
1
+ pytest_language_server-0.6.0.data/scripts/pytest-language-server,sha256=CEb5GynuHn3hI26OzcZMMYI75QMzwENz8JN6MmESnIw,8589088
2
+ pytest_language_server-0.6.0.dist-info/METADATA,sha256=YEjfn4uUamWoVZKEO9RMLWh0ibFfNl26vYN8qJtZ0fs,13464
3
+ pytest_language_server-0.6.0.dist-info/WHEEL,sha256=FoymBVbr67PzvGMLHywnjg0Vo0kUAVhpZT-_mKjzbig,104
4
+ pytest_language_server-0.6.0.dist-info/licenses/LICENSE,sha256=cVeSUfwn7g0UsWhiiGCIB-PKRr-Fut9GSN5NKDzYpTI,1072
5
+ pytest_language_server-0.6.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.10.1)
3
+ Root-Is-Purelib: false
4
+ Tag: py3-none-macosx_10_12_x86_64
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Patrick Arminio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.