Python: refactor PyError hierarchy, migrate to PyResult.

DO:
For upper-level (public) API use `PyResult`.
(Optionally) for low-level APIs inside your modules use python `Result<S, E>`.
Represent errors as `PyError` whenever possible.
Report `PyError` to `ErrorSink` at the top of your code.

DON'T:
Use `kotlin.Result`
Use `PyExecutionException`
Use any exception to represent user errors.

GitOrigin-RevId: 4ecf69e1fae8be9192cd33b90e0147c725a98964
This commit is contained in:
Ilya.Kazakevich
2025-04-28 17:52:06 +02:00
committed by intellij-monorepo-bot
parent d366245171
commit 803e270d45
74 changed files with 693 additions and 713 deletions

View File

@@ -9,7 +9,7 @@ import com.intellij.python.community.execService.HelperName
import com.intellij.python.community.execService.WhatToExec
import com.jetbrains.python.PythonBinary
import com.jetbrains.python.Result
import com.jetbrains.python.errorProcessing.PyError
import com.jetbrains.python.errorProcessing.PyResult
import com.jetbrains.python.errorProcessing.failure
import com.jetbrains.python.sdk.PySdkSettings
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor
@@ -36,7 +36,7 @@ suspend fun createVenv(
venvDir: Directory,
inheritSitePackages: Boolean = false,
envReader: VirtualEnvReader = VirtualEnvReader.Instance,
): Result<PythonBinary, PyError> {
): PyResult<PythonBinary> {
val execService = ExecService()
val args = buildList {
if (inheritSitePackages) {