From 1bb2332f0cdd794126e3c58bc1f7e3979b258a0a Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Fri, 31 Jan 2025 22:33:36 +0100 Subject: [PATCH] Python: `ExecService` API clean-up: it can only return `ExecException`, not `PyError` GitOrigin-RevId: ca635cc7b5b639cb5d6434f7f360d6ddf1de0eb1 --- .../src/com/intellij/python/community/execService/api.kt | 4 ++-- .../python/community/execService/impl/ExecServiceImpl.kt | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/python/python-exec-service/src/com/intellij/python/community/execService/api.kt b/python/python-exec-service/src/com/intellij/python/community/execService/api.kt index 86018c21cb9c..b9c432500e49 100644 --- a/python/python-exec-service/src/com/intellij/python/community/execService/api.kt +++ b/python/python-exec-service/src/com/intellij/python/community/execService/api.kt @@ -5,7 +5,7 @@ import com.intellij.platform.eel.EelApi import com.intellij.python.community.execService.impl.ExecServiceImpl import com.jetbrains.python.PythonBinary import com.jetbrains.python.Result -import com.jetbrains.python.errorProcessing.PyError +import com.jetbrains.python.errorProcessing.PyError.ExecException import org.jetbrains.annotations.ApiStatus import org.jetbrains.annotations.CheckReturnValue import org.jetbrains.annotations.Nls @@ -28,7 +28,7 @@ interface ExecService { */ @ApiStatus.Internal @CheckReturnValue - suspend fun execGetStdout(whatToExec: WhatToExec, args: List = emptyList(), processDescription: @Nls String? = null, timeout: Duration = 1.minutes): Result + suspend fun execGetStdout(whatToExec: WhatToExec, args: List = emptyList(), processDescription: @Nls String? = null, timeout: Duration = 1.minutes): Result } sealed interface WhatToExec { diff --git a/python/python-exec-service/src/com/intellij/python/community/execService/impl/ExecServiceImpl.kt b/python/python-exec-service/src/com/intellij/python/community/execService/impl/ExecServiceImpl.kt index b32a9bffc556..ba420eda06cf 100644 --- a/python/python-exec-service/src/com/intellij/python/community/execService/impl/ExecServiceImpl.kt +++ b/python/python-exec-service/src/com/intellij/python/community/execService/impl/ExecServiceImpl.kt @@ -12,7 +12,7 @@ import com.intellij.python.community.execService.ExecService import com.intellij.python.community.execService.WhatToExec import com.jetbrains.python.PythonHelpersLocator import com.jetbrains.python.Result -import com.jetbrains.python.errorProcessing.PyError +import com.jetbrains.python.errorProcessing.PyError.ExecException import com.jetbrains.python.errorProcessing.failure import com.jetbrains.python.execution.FailureReason import com.jetbrains.python.execution.userMessage @@ -25,7 +25,7 @@ import kotlin.time.Duration internal object ExecServiceImpl : ExecService { - override suspend fun execGetStdout(whatToExec: WhatToExec, args: List, processDescription: @Nls String?, timeout: Duration): Result { + override suspend fun execGetStdout(whatToExec: WhatToExec, args: List, processDescription: @Nls String?, timeout: Duration): Result { val (eel, exe, args) = when (whatToExec) { is WhatToExec.Binary -> Triple(whatToExec.binary.getEelDescriptor().upgrade(), whatToExec.binary.pathString, args) is WhatToExec.Helper -> { @@ -54,7 +54,7 @@ private suspend fun EelApi.execGetStdoutImpl( args: List, processDescription: @Nls String, timeout: Duration, -): Result { +): Result { val process = exec.executeProcess(exe, *args.toTypedArray()).getOr { err -> val text = PyExecBundle.message("py.exec.start.error", processDescription, err.error.message, err.error.errno) val failure = PyExecFailureImpl(exe, args, text, FailureReason.CantStart)