PY-86454: Autoconfigure python SDK even when there are several modules, but only one is python module.

We only autoconfigure SDK when there is one module. But there might be other (non-python) modules. We must ignore them.


(cherry picked from commit 6c45d3678aa16f54ba6967b24a8dd8afdb7fa2f6)

IJ-CR-196680

GitOrigin-RevId: 65dd0fbc6bcb6cc2abe123e820a1ae9dd4f60433
This commit is contained in:
Ilya.Kazakevich
2026-03-18 12:56:26 +00:00
committed by intellij-monorepo-bot
parent c73668b7b3
commit e1fd07e519
2 changed files with 5 additions and 2 deletions
@@ -214,12 +214,13 @@ fun TestFixture<Project>.moduleFixture(
fun TestFixture<Project>.moduleFixture(
pathFixture: TestFixture<Path>,
addPathToSourceRoot: Boolean = false,
moduleTypeId: String = ""
): TestFixture<Module> = testFixture { _ ->
val project = this@moduleFixture.init()
val path = pathFixture.init()
val manager = ModuleManager.getInstance(project)
val module = edtWriteAction {
manager.newModule(path, "")
manager.newModule(path, moduleTypeId)
}
if (addPathToSourceRoot) {
val pathVfs = withContext(Dispatchers.IO) {
@@ -19,6 +19,7 @@ import com.intellij.python.sdkConfigurator.common.impl.ModuleDTO
import com.intellij.python.sdkConfigurator.common.impl.ModuleName
import com.jetbrains.python.PathShortener
import com.jetbrains.python.Result
import com.jetbrains.python.module.PyModuleService
import com.jetbrains.python.sdk.configuration.CreateSdkInfo
import com.jetbrains.python.sdk.configuration.PyProjectSdkConfigurationExtension
import com.jetbrains.python.sdk.configuration.createSdk
@@ -187,7 +188,8 @@ internal class ModulesSdkConfigurator private constructor(
*/
@ApiStatus.Internal // Opened for tests only: we can't put tests here because configurators are in communuty.impl
suspend fun configureSdkAutomatically(project: Project): Unit = withContext(Dispatchers.Default) {
val modules = project.modules
val moduleService = PyModuleService.getInstance()
val modules = project.modules.filter { moduleService.isPythonModule(it) }
when (modules.size) {
0 -> return@withContext