Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ Only on Alpine Linux the package is named differently. You can install it there
apk add py3-lsp-server
```

Run `pylsp --version` (or `pylsp -V`) to see both the server version and the
Python version running it. This reports the server runtime, which may differ
from the interpreter or target Python version configured for individual plugins.

### 3rd Party Plugins

Installing these plugins will add extra functionality to the language server:
Expand Down
6 changes: 5 additions & 1 deletion pylsp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import argparse
import logging
import logging.config
import platform
import sys
import time

Expand Down Expand Up @@ -63,7 +64,10 @@ def add_arguments(parser) -> None:
)

parser.add_argument(
"-V", "--version", action="version", version="%(prog)s v" + __version__
"-V",
"--version",
action="version",
version=f"%(prog)s v{__version__} (Python {platform.python_version()})",
)


Expand Down
23 changes: 23 additions & 0 deletions test/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2021- Python Language Server Contributors.

import platform
import subprocess
import sys

import pytest

from pylsp._version import __version__


@pytest.mark.parametrize("flag", ["--version", "-V"])
def test_version_includes_python_runtime(flag):
result = subprocess.run(
[sys.executable, "-m", "pylsp", flag],
capture_output=True,
text=True,
check=True,
timeout=10,
)
assert f"v{__version__}" in result.stdout
assert f"Python {platform.python_version()}" in result.stdout
assert result.stderr == ""