PY-73001: improve toml stats, add one more test

GitOrigin-RevId: 177c87c825c8b0da937c23c5b0a9c299ab0fdda5
This commit is contained in:
Aleksandr Sorotskii
2024-06-26 14:02:55 +02:00
committed by intellij-monorepo-bot
parent 6675f5d123
commit 56cc278737
2 changed files with 16 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.findPsiFile
import com.intellij.psi.PsiFile
import com.intellij.psi.search.FileTypeIndex
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.search.ProjectScope
import com.jetbrains.python.packaging.PyRequirementParser
import org.jetbrains.annotations.ApiStatus.Internal
import org.jetbrains.annotations.VisibleForTesting
@@ -98,7 +98,7 @@ class PyProjectTomlUsageCollector : ProjectUsagesCollector() {
return@processFiles true
},
GlobalSearchScope.allScope(project))
ProjectScope.getContentScope(project))
val metrics = mutableSetOf<MetricEvent>()
tools.forEach { name ->

View File

@@ -29,7 +29,7 @@ class PyProjectTomlStatsTest : PyTestCase() {
val text = """
some abradackadabra
tools.autoflake
backend=autoflake
requires=autoflake
""".trimIndent()
doTest(text, emptySet(), emptySet())
@@ -92,6 +92,19 @@ class PyProjectTomlStatsTest : PyTestCase() {
doTest(text, emptySet(), setOf("hatchling", "flit"))
}
fun testCommentedBuilds() {
val text = """
[build-system]
requires = [
"hatchling >= 61",
# "flit",
]
build-backend = "xxxxyyy.build"
""".trimIndent()
doTest(text, emptySet(), setOf("hatchling"))
}
fun testNormalizeBuilds() {
val text = """
[build-system]