[PY-55968] poetry: detect dependencies in groups

(cherry picked from commit 6eb5da2a1ac45e2bae1831c9ae2ef22081f3c430)

IJ-MR-183124

GitOrigin-RevId: cba02910e4a11c38dfaf68b53a59a6e4102146d0
This commit is contained in:
KotlinIsland
2025-11-21 16:40:15 +10:00
committed by intellij-monorepo-bot
parent 24990ca39b
commit b0fd434d8f
2 changed files with 7 additions and 2 deletions

View File

@@ -181,7 +181,7 @@ fun parsePoetryShow(input: String): List<PythonPackage> {
@Internal
suspend fun poetryShowOutdated(sdk: Sdk): PyResult<Map<String, PythonOutdatedPackage>> {
val output = runPoetryWithSdk(sdk, "show", "--outdated").getOr { return it }
val output = runPoetryWithSdk(sdk, "show", "--all", "--outdated").getOr { return it }
return parsePoetryShowOutdated(output).let { PyResult.success(it) }
}

View File

@@ -48,6 +48,8 @@ internal class PoetryPackageVersionsInspection : LocalInspectionTool() {
@RequiresBackgroundThread
private fun Module.pyProjectTomlBlocking(): VirtualFile? = findAmongRoots(this, PY_PROJECT_TOML)
val poetryGroupRegex = Regex("""^tool\.poetry\.group\.[^.]*\.dependencies$""")
@RequiresBackgroundThread
override fun visitFile(psiFile: PsiFile) {
val module = guessModule(psiFile) ?: return
@@ -56,7 +58,10 @@ internal class PoetryPackageVersionsInspection : LocalInspectionTool() {
if (psiFile.virtualFile != module.pyProjectTomlBlocking()) return
psiFile.children
.filter { element ->
(element as? TomlTable)?.header?.key?.text in listOf("tool.poetry.dependencies", "tool.poetry.dev-dependencies")
(element as? TomlTable)?.header?.key?.text?.let { key ->
key in listOf("tool.poetry.dependencies", "tool.poetry.dev-dependencies") ||
poetryGroupRegex matches key
} ?: false
}.flatMap {
it.children.mapNotNull { line -> line as? TomlKeyValue }
}.forEach { keyValue ->