From b40c9187a4506204a770ab360ba627d698c0a101 Mon Sep 17 00:00:00 2001 From: dalthviz <16781833+dalthviz@users.noreply.github.com> Date: Mon, 27 Oct 2025 15:52:12 -0500 Subject: [PATCH] Prevent showing cmd on Windows when running flake8 --- .gitignore | 1 + pylsp/plugins/flake8_lint.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3c4093d1..fe35f067 100644 --- a/.gitignore +++ b/.gitignore @@ -100,6 +100,7 @@ ENV/ # Spyder project settings .spyderproject +.spyproject # Rope project settings .ropeproject diff --git a/pylsp/plugins/flake8_lint.py b/pylsp/plugins/flake8_lint.py index 0ac91855..b0a71b88 100644 --- a/pylsp/plugins/flake8_lint.py +++ b/pylsp/plugins/flake8_lint.py @@ -34,6 +34,13 @@ | {"E999"} ) +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 + @hookimpl def pylsp_settings(): @@ -128,7 +135,7 @@ def run_flake8(flake8_executable, args, document, source): ) log.debug("Calling %s with args: '%s'", flake8_executable, args) - popen_kwargs = {} + popen_kwargs = {"creationflags": CREATE_NO_WINDOW} if cwd := document._workspace.root_path: popen_kwargs["cwd"] = cwd try: