Skip to content

Commit 6a24326

Browse files
authored
Prevent showing cmd on Windows when running flake8 (#683)
1 parent 89265cd commit 6a24326

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ ENV/
100100

101101
# Spyder project settings
102102
.spyderproject
103+
.spyproject
103104

104105
# Rope project settings
105106
.ropeproject

pylsp/plugins/flake8_lint.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
| {"E999"}
3535
)
3636

37+
if sys.platform == "win32":
38+
from subprocess import CREATE_NO_WINDOW
39+
else:
40+
# CREATE_NO_WINDOW flag only available on Windows.
41+
# Set constant as default `Popen` `creationflag` kwarg value (`0`)
42+
CREATE_NO_WINDOW = 0
43+
3744

3845
@hookimpl
3946
def pylsp_settings():
@@ -128,7 +135,7 @@ def run_flake8(flake8_executable, args, document, source):
128135
)
129136

130137
log.debug("Calling %s with args: '%s'", flake8_executable, args)
131-
popen_kwargs = {}
138+
popen_kwargs = {"creationflags": CREATE_NO_WINDOW}
132139
if cwd := document._workspace.root_path:
133140
popen_kwargs["cwd"] = cwd
134141
try:

0 commit comments

Comments
 (0)