diff --git a/python/pluginResources/intellij.python.community.impl.xml b/python/pluginResources/intellij.python.community.impl.xml index d2dd8f382357..e04f386811e9 100644 --- a/python/pluginResources/intellij.python.community.impl.xml +++ b/python/pluginResources/intellij.python.community.impl.xml @@ -251,7 +251,7 @@ implementationClass="com.jetbrains.python.inspections.PyPep8Inspection" unfair="true"/> + implementationClass="com.jetbrains.python.inspections.interpreter.PyInterpreterInspection"/> = ArrayList() @@ -141,7 +151,7 @@ class PyInterpreterInspection : PyInspection() { } } - if (instance.suggestSharedCondaEnvironments) { + if (PyCondaSdkCustomizer.Companion.instance.suggestSharedCondaEnvironments) { val sharedCondaEnv = mostPreferred(filterSharedCondaEnvs(module, existingSdks)) if (sharedCondaEnv != null) { return UseExistingInterpreterFix(sharedCondaEnv, module) @@ -154,10 +164,10 @@ class PyInterpreterInspection : PyInspection() { return UseExistingInterpreterFix(systemWideSdk, module) } - val configurator = instance.fallbackConfigurator + val configurator = PyCondaSdkCustomizer.Companion.instance.fallbackConfigurator if (configurator != null) { val fallbackCreateSdkInfo = - checkEnvironmentAndPrepareSdkCreatorBlocking(configurator, module) + PyCondaSdkCustomizer.Companion.checkEnvironmentAndPrepareSdkCreatorBlocking(configurator, module) if (fallbackCreateSdkInfo != null) { return UseProvidedInterpreterFix(module, fallbackCreateSdkInfo) } @@ -176,7 +186,7 @@ class PyInterpreterInspection : PyInspection() { val model = ProjectSdksModel() model.reset(null) return ContainerUtil.filter(model.getSdks(), - Condition { it.getSdkType() is PythonSdkType }) + Condition { it.getSdkType() is PythonSdkType }) } private fun detectAssociatedViaRootNameEnv( @@ -188,7 +198,7 @@ class PyInterpreterInspection : PyInspection() { return Companion.findAssociatedViaRootNameEnv( associatedName, detectVirtualEnvs(module, existingSdks, context), - Function { sdk: PyDetectedSdk? -> Companion.getVirtualEnvRootName(sdk!!) } + Function { sdk: PyDetectedSdk? -> getVirtualEnvRootName(sdk!!) } ) } @@ -254,7 +264,7 @@ class PyInterpreterInspection : PyInspection() { val id = "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" val group = ConfigurableExtensionPointUtil.getConfigurableGroup(project, true) if (ConfigurableVisitor.findById(id, mutableListOf(group)) != null) { - showSettingsDialog(project, id, null) + ShowSettingsUtilImpl.Companion.showSettingsDialog(project, id, null) return } @@ -269,7 +279,7 @@ class PyInterpreterInspection : PyInspection() { private fun justOneModuleInheritingSdk(project: Project, module: Module): Boolean { return ProjectRootManager.getInstance(project).getProjectSdk() == null && - ModuleRootManager.getInstance(module).isSdkInherited() && getInstance(project).modules.size < 2 + ModuleRootManager.getInstance(module).isSdkInherited() && ModuleManager.Companion.getInstance(project).modules.size < 2 } } } @@ -291,7 +301,7 @@ class PyInterpreterInspection : PyInspection() { val module = ModuleUtilCore.findModuleForPsiElement(element) if (module == null) return - createAndShow(module) + PySdkPopupFactory.Companion.createAndShow(module) } } @@ -311,7 +321,7 @@ class PyInterpreterInspection : PyInspection() { override fun applyFix(project: Project, descriptor: ProblemDescriptor) { if (!detectSdkForModulesForJvmIn(project)) { - configureSdkUsingCreateSdkInfo(myModule, myCreateSdkInfo) + PyProjectSdkConfiguration.configureSdkUsingCreateSdkInfo(myModule, myCreateSdkInfo) } } @@ -368,4 +378,4 @@ class PyInterpreterInspection : PyInspection() { } } } -} +} \ No newline at end of file diff --git a/python/src/com/jetbrains/python/inspections/PyInterpreterInspectionEx.kt b/python/src/com/jetbrains/python/inspections/interpreter/PyInterpreterInspectionEx.kt similarity index 96% rename from python/src/com/jetbrains/python/inspections/PyInterpreterInspectionEx.kt rename to python/src/com/jetbrains/python/inspections/interpreter/PyInterpreterInspectionEx.kt index 79bd979bc294..d98b3c00fac3 100644 --- a/python/src/com/jetbrains/python/inspections/PyInterpreterInspectionEx.kt +++ b/python/src/com/jetbrains/python/inspections/interpreter/PyInterpreterInspectionEx.kt @@ -1,5 +1,5 @@ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.jetbrains.python.inspections +package com.jetbrains.python.inspections.interpreter import com.intellij.openapi.components.Service import com.intellij.openapi.components.service diff --git a/python/src/com/jetbrains/python/packaging/toolwindow/PyPackagingToolWindowPanel.kt b/python/src/com/jetbrains/python/packaging/toolwindow/PyPackagingToolWindowPanel.kt index 3af124705ff7..9d63bdef86ab 100644 --- a/python/src/com/jetbrains/python/packaging/toolwindow/PyPackagingToolWindowPanel.kt +++ b/python/src/com/jetbrains/python/packaging/toolwindow/PyPackagingToolWindowPanel.kt @@ -28,7 +28,7 @@ import com.intellij.ui.SimpleTextAttributes import com.intellij.util.asDisposable import com.jetbrains.python.PyBundle.message import com.jetbrains.python.TraceContext -import com.jetbrains.python.inspections.PyInterpreterInspection +import com.jetbrains.python.inspections.interpreter.PyInterpreterInspection import com.jetbrains.python.packaging.toolwindow.details.PyPackageInfoPanel import com.jetbrains.python.packaging.toolwindow.model.DisplayablePackage import com.jetbrains.python.packaging.toolwindow.model.ErrorNode diff --git a/python/src/com/jetbrains/python/sdk/PySdkExt.kt b/python/src/com/jetbrains/python/sdk/PySdkExt.kt index ba791a97e43f..a47c2413ada0 100644 --- a/python/src/com/jetbrains/python/sdk/PySdkExt.kt +++ b/python/src/com/jetbrains/python/sdk/PySdkExt.kt @@ -464,7 +464,7 @@ fun getInnerVirtualEnvRoot(sdk: Sdk): VirtualFile? { } internal suspend fun suggestAssociatedSdkName(sdkHome: String, associatedPath: String?): String? = withContext(Dispatchers.IO) { - // please don't forget to update com.jetbrains.python.inspections.PyInterpreterInspection.Visitor#getSuitableSdkFix + // please don't forget to update com.jetbrains.python.inspections.interpreter.PyInterpreterInspection.Visitor#getSuitableSdkFix // after changing this method val baseSdkName = PythonSdkType.suggestBaseSdkName(sdkHome) ?: return@withContext null diff --git a/python/src/com/jetbrains/python/sdk/PySdkPopupFactory.kt b/python/src/com/jetbrains/python/sdk/PySdkPopupFactory.kt index f04320897117..afeaf80ff80e 100644 --- a/python/src/com/jetbrains/python/sdk/PySdkPopupFactory.kt +++ b/python/src/com/jetbrains/python/sdk/PySdkPopupFactory.kt @@ -16,7 +16,7 @@ import com.intellij.util.text.trimMiddle import com.intellij.util.ui.SwingHelper import com.jetbrains.python.PyBundle import com.jetbrains.python.configuration.PyConfigurableInterpreterList -import com.jetbrains.python.inspections.PyInterpreterInspection +import com.jetbrains.python.inspections.interpreter.PyInterpreterInspection import com.jetbrains.python.psi.LanguageLevel import com.jetbrains.python.run.PythonInterpreterTargetEnvironmentFactory import com.jetbrains.python.run.codeCouldProbablyBeRunWithConfig diff --git a/python/testSrc/com/jetbrains/python/inspections/PyInterpreterInspectionTest.kt b/python/testSrc/com/jetbrains/python/inspections/PyInterpreterInspectionTest.kt index ca0ea13552c6..e2f610fa6baf 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyInterpreterInspectionTest.kt +++ b/python/testSrc/com/jetbrains/python/inspections/PyInterpreterInspectionTest.kt @@ -8,6 +8,7 @@ import com.intellij.openapi.roots.ProjectRootManager import com.intellij.testFramework.LightProjectDescriptor import com.jetbrains.python.PyPsiBundle import com.jetbrains.python.fixtures.PyTestCase +import com.jetbrains.python.inspections.interpreter.PyInterpreterInspection class PyInterpreterInspectionTest : PyTestCase() { override fun getProjectDescriptor(): LightProjectDescriptor? = ourPyLatestDescriptor