From 14f1f6bfe4d654017acc1d4996cdff4c41d0d892 Mon Sep 17 00:00:00 2001 From: David Lysenko Date: Wed, 6 Aug 2025 17:18:54 +0200 Subject: [PATCH] [pycharm] PY-79132 Address feedback GitOrigin-RevId: 03e4786ad9e32de518a11b2cad6a8b653e2cc1f8 --- python/pluginResources/messages/PyBundle.properties | 2 +- .../jetbrains/python/sdk/add/v2/uv/EnvironmentCreatorUv.kt | 7 +++---- python/src/com/jetbrains/python/sdk/uv/Uv.kt | 2 +- python/src/com/jetbrains/python/sdk/uv/impl/UvLowLevel.kt | 7 +++++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/python/pluginResources/messages/PyBundle.properties b/python/pluginResources/messages/PyBundle.properties index f96cbd7ab27b..633bb2855df0 100644 --- a/python/pluginResources/messages/PyBundle.properties +++ b/python/pluginResources/messages/PyBundle.properties @@ -423,7 +423,7 @@ python.sdk.uv.associated.project=Associated project: python.sdk.uv.environment.panel.title=uv environment python.sdk.uv.executable.not.found=uv executable is not found python.sdk.uv.executable=uv executable: -python.sdk.uv.install.packages.from.toml.checkbox.text=Install packages from pyproject.toml +python.sdk.uv.default.version=Default python.sdk.local=Local python.sdk.creating.python.module.structure=Creating Python Module Structure diff --git a/python/src/com/jetbrains/python/sdk/add/v2/uv/EnvironmentCreatorUv.kt b/python/src/com/jetbrains/python/sdk/add/v2/uv/EnvironmentCreatorUv.kt index a8d043c8be9a..b52cdb73bbd1 100644 --- a/python/src/com/jetbrains/python/sdk/add/v2/uv/EnvironmentCreatorUv.kt +++ b/python/src/com/jetbrains/python/sdk/add/v2/uv/EnvironmentCreatorUv.kt @@ -9,6 +9,7 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.projectRoots.Sdk import com.intellij.openapi.ui.ComboBox import com.intellij.openapi.ui.validation.DialogValidationRequestor +import com.intellij.python.pyproject.PY_PROJECT_TOML import com.intellij.python.pyproject.PyProjectToml import com.intellij.ui.dsl.builder.AlignX import com.intellij.ui.dsl.builder.Panel @@ -75,7 +76,7 @@ internal class EnvironmentCreatorUv( row(message("sdk.create.python.version")) { pythonVersion = propertyGraph.property(null) versionComboBox = comboBox(listOf(null), textListCellRenderer { - it?.let { "${it.major}.${it.minor}" } ?: "Default" + it?.let { "${it.major}.${it.minor}" } ?: message("python.sdk.uv.default.version") }) .bindItem(pythonVersion) .enabledIf(loading.not()) @@ -131,7 +132,7 @@ internal class EnvironmentCreatorUv( try { loading.set(true) - val pyProjectTomlPath = projectPath.resolve("pyproject.toml") + val pyProjectTomlPath = projectPath.resolve(PY_PROJECT_TOML) val pythonVersions = withContext(Dispatchers.IO) { val versionRequest = if (pyProjectTomlPath.exists()) { @@ -144,8 +145,6 @@ internal class EnvironmentCreatorUv( val uvLowLevel = createUvLowLevel(Path.of(""), cli) uvLowLevel.listSupportedPythonVersions(versionRequest) .getOr { return@withContext emptyList() } - .toList() - .sortedDescending() } pythonVersions.forEach { diff --git a/python/src/com/jetbrains/python/sdk/uv/Uv.kt b/python/src/com/jetbrains/python/sdk/uv/Uv.kt index faf13a5262f0..12d9f494af99 100644 --- a/python/src/com/jetbrains/python/sdk/uv/Uv.kt +++ b/python/src/com/jetbrains/python/sdk/uv/Uv.kt @@ -21,7 +21,7 @@ interface UvLowLevel { suspend fun initializeEnvironment(init: Boolean, version: Version?): PyResult suspend fun listUvPythons(): PyResult> - suspend fun listSupportedPythonVersions(versionRequest: String? = null): PyResult> + suspend fun listSupportedPythonVersions(versionRequest: String? = null): PyResult> /** * Manage project dependencies by adding/removing them to the project along side installation diff --git a/python/src/com/jetbrains/python/sdk/uv/impl/UvLowLevel.kt b/python/src/com/jetbrains/python/sdk/uv/impl/UvLowLevel.kt index 3ff90040f292..d48644536fd9 100644 --- a/python/src/com/jetbrains/python/sdk/uv/impl/UvLowLevel.kt +++ b/python/src/com/jetbrains/python/sdk/uv/impl/UvLowLevel.kt @@ -91,7 +91,7 @@ private class UvLowLevelImpl(val cwd: Path, private val uvCli: UvCli) : UvLowLev return PyResult.success(pythons) } - override suspend fun listSupportedPythonVersions(versionRequest: String?): PyResult> { + override suspend fun listSupportedPythonVersions(versionRequest: String?): PyResult> { val args = mutableListOf("python", "list") if (versionRequest != null) { @@ -107,7 +107,10 @@ private class UvLowLevelImpl(val cwd: Path, private val uvCli: UvCli) : UvLowLev it.groupValues[1], strict = false ) - }.toSet() + } + .toSet() + .toList() + .sortedDescending() ) }