From 43618513c045af30f90d344891522f98eb9ed7fc Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Wed, 30 Apr 2025 13:55:05 +0200 Subject: [PATCH] Python: make `runExecutable` interface return the only error it can return GitOrigin-RevId: 30f11900a7bf1085c405d92e6f58f771ed1c9004 --- .../src/com/jetbrains/python/errorProcessing/PyResult.kt | 4 ++++ python/src/com/jetbrains/python/sdk/PySdkCommandRunner.kt | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/python/openapi/src/com/jetbrains/python/errorProcessing/PyResult.kt b/python/openapi/src/com/jetbrains/python/errorProcessing/PyResult.kt index 11a63083f9de..a8916e84c6ec 100644 --- a/python/openapi/src/com/jetbrains/python/errorProcessing/PyResult.kt +++ b/python/openapi/src/com/jetbrains/python/errorProcessing/PyResult.kt @@ -8,6 +8,10 @@ import com.jetbrains.python.packaging.PyExecutionException * Use it instead of exceptions and Kotlin Result. */ typealias PyResult = com.jetbrains.python.Result +/** + * Like [PyResult] but error is always [ExecError] + */ +typealias PyExecResult = com.jetbrains.python.Result inline fun failure(pyError: T): com.jetbrains.python.Result.Failure = com.jetbrains.python.Result.Companion.failure(pyError) diff --git a/python/src/com/jetbrains/python/sdk/PySdkCommandRunner.kt b/python/src/com/jetbrains/python/sdk/PySdkCommandRunner.kt index 120a7d95296a..c41b00731777 100644 --- a/python/src/com/jetbrains/python/sdk/PySdkCommandRunner.kt +++ b/python/src/com/jetbrains/python/sdk/PySdkCommandRunner.kt @@ -4,7 +4,7 @@ package com.jetbrains.python.sdk import com.intellij.python.community.execService.ExecOptions import com.intellij.python.community.execService.ExecService import com.intellij.python.community.execService.WhatToExec -import com.jetbrains.python.errorProcessing.PyResult +import com.jetbrains.python.errorProcessing.PyExecResult import org.jetbrains.annotations.ApiStatus.Internal import java.nio.file.Path @@ -17,5 +17,5 @@ import java.nio.file.Path * @return A [Result] object containing the output of the command execution. */ @Internal -suspend fun runExecutable(executable: Path, projectPath: Path?, vararg args: String): PyResult = +suspend fun runExecutable(executable: Path, projectPath: Path?, vararg args: String): PyExecResult = ExecService().execGetStdout(WhatToExec.Binary(executable), args.toList(), ExecOptions(workingDirectory = projectPath)) \ No newline at end of file