From 17c0f647d60fd5e70dca8f07bd9e2c372bfaaa60 Mon Sep 17 00:00:00 2001 From: Alexey Katsman Date: Fri, 20 Feb 2026 16:42:58 +0100 Subject: [PATCH] PY-87265 Check tool. in pyproject.toml-based projects Before the changes, we didn't check tool specific info in pyproject.toml. This led to an effect when you've had a uv module (with tool.uv.* sections specified), but also hatchling build system. And since we're checking for a build system, we suggest to configure a project using Hatch, which is incorrect. (cherry picked from commit 9e5195e2e3c97d4772065528344aaf7c8533841b) IJ-MR-192700 GitOrigin-RevId: aea284c87fb78e1c6029b07f2a290e10a4151399 --- .../model/internal/workspaceBridge/workspaceTools.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/python/python-pyproject/src/com/intellij/python/pyproject/model/internal/workspaceBridge/workspaceTools.kt b/python/python-pyproject/src/com/intellij/python/pyproject/model/internal/workspaceBridge/workspaceTools.kt index 524e56cb9e10..8f5305bac0cd 100644 --- a/python/python-pyproject/src/com/intellij/python/pyproject/model/internal/workspaceBridge/workspaceTools.kt +++ b/python/python-pyproject/src/com/intellij/python/pyproject/model/internal/workspaceBridge/workspaceTools.kt @@ -138,10 +138,18 @@ private suspend fun generatePyProjectTomlEntries( } usedNamed.add(projectNameAsString) val projectName = ProjectName(projectNameAsString) - val sourceRootsAndTools = Tool.EP.extensionList.flatMap { tool -> tool.getSrcRoots(toml.toml, root).map { Pair(tool, it) } }.toSet() + val sourceRootsAndTools = tools.flatMap { tool -> tool.getSrcRoots(toml.toml, root).map { Pair(tool, it) } }.toSet() val sourceRoots = sourceRootsAndTools.map { it.second }.toSet() + findSrc(root) participatedTools.addAll(sourceRootsAndTools.map { it.first.id }) val excludedDirs = allExcludeDirs.filter { it.startsWith(root) } + if (participatedTools.isEmpty()) { + // If a tool is mentioned as a tool. in pyproject.toml, we consider it participated in project configuration + for (tool in tools) { + if (toml.toml.contains("tool.${tool.id.id}")) { + participatedTools.add(tool.id) + } + } + } if (participatedTools.isEmpty()) { // Try to use build-tool as last resort toml.toml.getString("build-system.build-backend")?.let { buildBackend ->