From 8412943f4f05b1e44d189a0f02ca848b720a65c3 Mon Sep 17 00:00:00 2001 From: Wu Zhenyu Date: Sun, 11 Feb 2024 08:58:58 +0800 Subject: [PATCH] :bug: Raise error when input is invalid --- mdformat_ruff/__init__.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/mdformat_ruff/__init__.py b/mdformat_ruff/__init__.py index 1310c07..86b5efe 100644 --- a/mdformat_ruff/__init__.py +++ b/mdformat_ruff/__init__.py @@ -16,11 +16,6 @@ def format_python(unformatted: str, _info_str: str) -> str: :type _info_str: str :rtype: str """ - ps = subprocess.run( - [find_ruff_bin(), "format", "-"], - input=unformatted.encode(), - capture_output=True, - ) - if ps.returncode == 0: - return ps.stdout.decode() - return unformatted + return subprocess.check_output( + [find_ruff_bin(), "format", "-"], input=unformatted.encode() + ).decode()