mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-57391: Filter Conda language levels for new envs
GitOrigin-RevId: a619242c400bba201eb2e096062add9b8529a7ff
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c5142d33cb
commit
c7ccd35a26
@@ -22,10 +22,9 @@ import com.intellij.util.ui.FormBuilder
|
||||
import com.jetbrains.python.PyBundle
|
||||
import com.jetbrains.python.packaging.PyCondaPackageManagerImpl
|
||||
import com.jetbrains.python.packaging.PyCondaPackageService
|
||||
import com.jetbrains.python.psi.LanguageLevel
|
||||
import com.jetbrains.python.sdk.*
|
||||
import com.jetbrains.python.sdk.add.target.conda.condaSupportedLanguages
|
||||
import com.jetbrains.python.sdk.conda.PyCondaSdkCustomizer
|
||||
import com.jetbrains.python.sdk.fixPythonCondaSdk
|
||||
import com.jetbrains.python.sdk.flavors.conda.CondaEnvSdkFlavor
|
||||
import icons.PythonIcons
|
||||
import org.jetbrains.annotations.SystemIndependent
|
||||
@@ -77,9 +76,7 @@ open class PyAddNewCondaEnvPanel(
|
||||
init {
|
||||
layout = BorderLayout()
|
||||
|
||||
val supportedLanguageLevels = LanguageLevel.SUPPORTED_LEVELS
|
||||
.asReversed()
|
||||
.filter { it < LanguageLevel.PYTHON311 }
|
||||
val supportedLanguageLevels = condaSupportedLanguages
|
||||
.map { it.toPythonVersion() }
|
||||
|
||||
languageLevelsField = ComboBox(supportedLanguageLevels.toTypedArray()).apply {
|
||||
|
||||
@@ -45,7 +45,7 @@ class PyAddCondaPanelModel(val targetConfiguration: TargetEnvironmentConfigurati
|
||||
/**
|
||||
* Python versions for new environment
|
||||
*/
|
||||
val languageLevels: List<LanguageLevel> = LanguageLevel.values().toList()
|
||||
val languageLevels: List<LanguageLevel> = condaSupportedLanguages
|
||||
|
||||
val condaPathFileChooser: FileChooserDescriptor = object : FileChooserDescriptor(true, false, false, false, false, false) {
|
||||
override fun isFileVisible(file: VirtualFile?, showHiddenFiles: Boolean): Boolean =
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.projectRoots.Sdk
|
||||
import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl
|
||||
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil
|
||||
import com.jetbrains.python.psi.LanguageLevel
|
||||
import com.jetbrains.python.sdk.PythonSdkAdditionalData
|
||||
import com.jetbrains.python.sdk.PythonSdkType
|
||||
import com.jetbrains.python.sdk.flavors.PyFlavorAndData
|
||||
@@ -25,6 +26,14 @@ import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.io.path.isExecutable
|
||||
import kotlin.io.path.pathString
|
||||
|
||||
/**
|
||||
* Levels to be used for new conda envs
|
||||
*/
|
||||
val condaSupportedLanguages: List<LanguageLevel>
|
||||
get() = LanguageLevel.SUPPORTED_LEVELS
|
||||
.asReversed()
|
||||
.filter { it < LanguageLevel.PYTHON311 }
|
||||
|
||||
/**
|
||||
* See [com.jetbrains.env.conda.PyCondaSdkTest]
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,8 @@ import com.jetbrains.python.sdk.flavors.conda.PyCondaFlavorData
|
||||
import com.jetbrains.python.sdk.getOrCreateAdditionalData
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.hamcrest.MatcherAssert
|
||||
import org.hamcrest.Matchers.*
|
||||
import org.junit.Assert
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -52,6 +54,9 @@ class PyAddCondaPanelModelTest {
|
||||
model.condaPathTextBoxRwProp.set(condaRule.condaPath.toString())
|
||||
model.condaActionCreateNewEnvRadioRwProp.set(true)
|
||||
model.condaActionUseExistingEnvRadioRwProp.set(false)
|
||||
|
||||
MatcherAssert.assertThat("No 3.9 suggested", model.languageLevels, hasItem(LanguageLevel.PYTHON39))
|
||||
MatcherAssert.assertThat("2.6 suggested", model.languageLevels, not(hasItem(LanguageLevel.PYTHON26)))
|
||||
model.newEnvLanguageLevelRwProperty.set(LanguageLevel.PYTHON38)
|
||||
Assert.assertNotNull("Empty conda env name didn't lead to validation", model.getValidationError())
|
||||
model.newEnvNameRwProperty.set("d f --- ")
|
||||
@@ -82,8 +87,7 @@ class PyAddCondaPanelModelTest {
|
||||
model.condaActionUseExistingEnvRadioRwProp.set(false)
|
||||
model.newEnvLanguageLevelRwProperty.set(LanguageLevel.PYTHON38)
|
||||
model.newEnvNameRwProperty.set(name)
|
||||
Assert.assertEquals("Name duplicate should lead to error",
|
||||
PyBundle.message("python.sdk.conda.problem.env.name.used"),
|
||||
Assert.assertEquals("Name duplicate should lead to error", PyBundle.message("python.sdk.conda.problem.env.name.used"),
|
||||
model.getValidationError())
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user