Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ __pycache__/
*.swp
tags
/build/

.spyproject/
11 changes: 9 additions & 2 deletions pylsp_ruff/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
from subprocess import PIPE, Popen
from typing import Dict, Generator, List, Optional

if sys.platform == "win32":
from subprocess import CREATE_NO_WINDOW
else:
# CREATE_NO_WINDOW flag only available on Windows.
# Set constant as default `Popen` `creationflag` kwarg value (`0`)
CREATE_NO_WINDOW = 0

if sys.version_info >= (3, 11):
import tomllib
else:
Expand Down Expand Up @@ -502,7 +509,7 @@ def find_executable(executable) -> List[str]:
# try the python module
if cmd is None:
if importlib.util.find_spec("ruff") is not None:
cmd = [sys.executable, "-m", "ruff"]
cmd = [sys.executable.replace("pythonw", "python"), "-m", "ruff"]

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

log.debug(f"Calling {cmd} on '{document_path}'")
p = Popen(cmd, stdin=PIPE, stdout=PIPE)
p = Popen(cmd, stdin=PIPE, stdout=PIPE, creationflags=CREATE_NO_WINDOW)
(stdout, _) = p.communicate(document_source.encode())

if p.returncode != 0:
Expand Down