| 591 | return await super().start() |
| 592 | |
| 593 | def validate_requirements(self) -> str | Literal[True]: |
| 594 | if not DependencyManager.pylsp.has(): |
| 595 | return "pylsp is missing. Install it with `pip install python-lsp-server`." |
| 596 | |
| 597 | # Try actually running pylsp to validate it works |
| 598 | import sys |
| 599 | |
| 600 | try: |
| 601 | result = subprocess.run( |
| 602 | [sys.executable, "-m", "pylsp", "--version"], |
| 603 | capture_output=True, |
| 604 | text=True, |
| 605 | timeout=5, |
| 606 | ) |
| 607 | if result.returncode != 0: |
| 608 | error_msg = result.stderr or result.stdout or "Unknown error" |
| 609 | return f"pylsp is installed but failed to run: {error_msg}. Check for dependency conflicts (e.g., jedi version compatibility)." |
| 610 | return True |
| 611 | except subprocess.TimeoutExpired: |
| 612 | return "pylsp command timed out. The server may be unresponsive." |
| 613 | except Exception as e: |
| 614 | return f"Failed to validate pylsp: {e}" |
| 615 | |
| 616 | def get_command(self) -> list[str]: |
| 617 | import sys |