mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
PY-79488 Don't report a uv module SDK associated with a workspace root
All uv workspace members and its root share the same virtual environment. When configuring an SDK for one of the corresponding modules with a quickfix, we now associate it with the workspace root and then don't report for member modules that their SDK belongs to the root module. GitOrigin-RevId: a7778e302b9a86b4b446c4300524505ea500ea57
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b7013f8b0a
commit
5524cf2451
@@ -61,15 +61,15 @@ class PyUvSdkConfiguration : PyProjectSdkConfigurationExtension {
|
||||
override fun supportsHeadlessModel(): Boolean = true
|
||||
|
||||
private suspend fun createUv(module: Module): PyResult<Sdk> {
|
||||
val venvParentDir: String?
|
||||
val sdkAssociatedModule: Module
|
||||
if (Registry.`is`("python.project.model.uv", false)) {
|
||||
val uvWorkspace = UvProjectModelService.findWorkspace(module)
|
||||
venvParentDir = uvWorkspace?.root?.basePath ?: module.basePath
|
||||
sdkAssociatedModule = uvWorkspace?.root ?: module
|
||||
}
|
||||
else {
|
||||
venvParentDir = module.basePath
|
||||
sdkAssociatedModule = module
|
||||
}
|
||||
val workingDir: Path? = tryResolvePath(venvParentDir)
|
||||
val workingDir: Path? = tryResolvePath(sdkAssociatedModule.basePath)
|
||||
if (workingDir == null) {
|
||||
return PyResult.failure(MessageError("Can't determine working dir for the module"))
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class PyUvSdkConfiguration : PyProjectSdkConfigurationExtension {
|
||||
sdk.onSuccess {
|
||||
withContext(Dispatchers.EDT) {
|
||||
SdkConfigurationUtil.addSdk(it)
|
||||
it.setAssociationToModule(module)
|
||||
it.setAssociationToModule(sdkAssociatedModule)
|
||||
}
|
||||
}
|
||||
return sdk
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.platform.backend.workspace.WorkspaceModelChangeListener;
|
||||
import com.intellij.platform.workspace.jps.entities.ModuleEntity;
|
||||
import com.intellij.platform.workspace.storage.EntityChange;
|
||||
@@ -42,6 +43,8 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleEntityUtils;
|
||||
import com.jetbrains.python.PyPsiBundle;
|
||||
import com.jetbrains.python.PythonIdeLanguageCustomization;
|
||||
import com.jetbrains.python.projectModel.uv.UvProjectModelService;
|
||||
import com.jetbrains.python.projectModel.uv.UvProjectModelService.UvWorkspace;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.psi.PyFile;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
@@ -124,7 +127,9 @@ public final class PyInterpreterInspection extends PyInspection {
|
||||
}
|
||||
else {
|
||||
final @NlsSafe String associatedModulePath = PySdkExtKt.getAssociatedModulePath(sdk);
|
||||
if (!PlatformUtils.isFleetBackend() && (associatedModulePath == null || PySdkExtKt.isAssociatedWithAnotherModule(sdk, module))) {
|
||||
if (!PlatformUtils.isFleetBackend() &&
|
||||
(associatedModulePath == null || PySdkExtKt.isAssociatedWithAnotherModule(sdk, module)) &&
|
||||
!(Registry.is("python.project.model.uv", false) && isAssociatedWithUvWorkspaceRootModule(associatedModulePath, module))) {
|
||||
final PyInterpreterInspectionQuickFixData fixData = PySdkProvider.EP_NAME.getExtensionList().stream()
|
||||
.map(ext -> ext.createEnvironmentAssociationFix(module, sdk, pyCharm, associatedModulePath))
|
||||
.filter(it -> it != null)
|
||||
@@ -167,6 +172,13 @@ public final class PyInterpreterInspection extends PyInspection {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isAssociatedWithUvWorkspaceRootModule(@Nullable String sdkAssociatedPath, @NotNull Module module) {
|
||||
if (sdkAssociatedPath == null) return false;
|
||||
UvWorkspace<@NotNull Module> uvWorkspace = UvProjectModelService.INSTANCE.findWorkspace(module);
|
||||
if (uvWorkspace == null) return false;
|
||||
return sdkAssociatedPath.equals(BasePySdkExtKt.getBasePath(uvWorkspace.getRoot()));
|
||||
}
|
||||
|
||||
private void registerProblemWithCommonFixes(PyFile node,
|
||||
@InspectionMessage String message,
|
||||
Module module,
|
||||
|
||||
Reference in New Issue
Block a user