Skip to content

Commit 785c071

Browse files
authored
Merge branch 'main' into add_unfixable
2 parents 76ec182 + 5928f5f commit 785c071

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ __pycache__/
44
*.swp
55
tags
66
/build/
7+
8+
.spyproject/

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
[![Anaconda](https://anaconda.org/conda-forge/python-lsp-ruff/badges/version.svg)](https://anaconda.org/conda-forge/python-lsp-ruff)
55
[![Python](https://github.com/python-lsp/python-lsp-ruff/actions/workflows/python.yml/badge.svg)](https://github.com/python-lsp/python-lsp-ruff/actions/workflows/python.yml)
66

7-
`python-lsp-ruff` is a plugin for `python-lsp-server` that adds linting, code action and formatting capabilities that are provided by [ruff](https://github.com/charliermarsh/ruff),
7+
`python-lsp-ruff` is a plugin for `python-lsp-server` that adds **linting**, **code actions** and **formatting** capabilities that are provided by [ruff](https://github.com/charliermarsh/ruff),
88
an extremely fast Python linter and formatter written in Rust.
99

10+
Note that `ruff>0.4.5` ships with a built-in LSP server (and `ruff-lsp` before that), which allows linting, formatting and code actions.
11+
In contrast, this implementation adds `ruff` as a plugin for `pylsp` in addition to `pylsp`'s other functionalities (go-to support, ...).
12+
1013
## Install
1114

1215
In the same `virtualenv` as `python-lsp-server`:

SECURITY.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Security Policy
2+
3+
4+
## Supported Versions
5+
6+
We normally support only the most recently released version with bug fixes, security updates and compatibility improvements.
7+
8+
9+
## Reporting a Vulnerability
10+
11+
If you believe you've discovered a security vulnerability in this project, please open a new security advisory with [our GitHub repo's private vulnerability reporting](https://github.com/python-lsp/python-lsp-ruff/security/advisories/new).
12+
Please be sure to carefully document the vulnerability, including a summary, describing the impacts, identifying the line(s) of code affected, stating the conditions under which it is exploitable and including a minimal reproducible test case.
13+
Further information and advice or patches on how to mitigate it is always welcome.
14+
You can usually expect to hear back within 1 week, at which point we'll inform you of our evaluation of the vulnerability and what steps we plan to take, and will reach out if we need further clarification from you.
15+
We'll discuss and update the advisory thread, and are happy to update you on its status should you further inquire.
16+
While this is a volunteer project and we don't have financial compensation to offer, we can certainly publicly thank and credit you for your help if you would like.
17+
Thanks!

pylsp_ruff/plugin.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
from subprocess import PIPE, Popen
1111
from typing import Dict, Generator, List, Optional
1212

13+
if sys.platform == "win32":
14+
from subprocess import CREATE_NO_WINDOW
15+
else:
16+
# CREATE_NO_WINDOW flag only available on Windows.
17+
# Set constant as default `Popen` `creationflag` kwarg value (`0`)
18+
CREATE_NO_WINDOW = 0
19+
1320
if sys.version_info >= (3, 11):
1421
import tomllib
1522
else:
@@ -502,7 +509,7 @@ def find_executable(executable) -> List[str]:
502509
# try the python module
503510
if cmd is None:
504511
if importlib.util.find_spec("ruff") is not None:
505-
cmd = [sys.executable, "-m", "ruff"]
512+
cmd = [sys.executable.replace("pythonw", "python"), "-m", "ruff"]
506513

507514
# try system's ruff executable
508515
if cmd is None:
@@ -557,7 +564,7 @@ def run_ruff(
557564
cmd = [*find_executable(executable), str(subcommand), *arguments]
558565

559566
log.debug(f"Calling {cmd} on '{document_path}'")
560-
p = Popen(cmd, stdin=PIPE, stdout=PIPE)
567+
p = Popen(cmd, stdin=PIPE, stdout=PIPE, creationflags=CREATE_NO_WINDOW)
561568
(stdout, _) = p.communicate(document_source.encode())
562569

563570
if p.returncode != 0:

0 commit comments

Comments
 (0)