Skip to content

Commit 5c84958

Browse files
committed
Prevent showing cmd on Windows and add handling for ruff execution with pythonw
1 parent a0a33a6 commit 5c84958

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-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/

pylsp_ruff/plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import sys
88
from functools import lru_cache
99
from pathlib import PurePath
10-
from subprocess import PIPE, Popen
10+
from subprocess import CREATE_NO_WINDOW, PIPE, Popen
1111
from typing import Dict, Generator, List, Optional
1212

1313
if sys.version_info >= (3, 11):
@@ -502,7 +502,7 @@ def find_executable(executable) -> List[str]:
502502
# try the python module
503503
if cmd is None:
504504
if importlib.util.find_spec("ruff") is not None:
505-
cmd = [sys.executable, "-m", "ruff"]
505+
cmd = [sys.executable.replace("pythonw", "python"), "-m", "ruff"]
506506

507507
# try system's ruff executable
508508
if cmd is None:
@@ -557,7 +557,7 @@ def run_ruff(
557557
cmd = [*find_executable(executable), str(subcommand), *arguments]
558558

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

563563
if p.returncode != 0:

0 commit comments

Comments
 (0)