[python] fix fus logging for daemon imports PY-63929

GitOrigin-RevId: 93402487cd40ceea9a2b1023e030a82a4979f84c
This commit is contained in:
Vladimir Koshelev
2023-11-07 14:45:29 +01:00
committed by intellij-monorepo-bot
parent ebec43c5f7
commit 342ca8a239
2 changed files with 4 additions and 3 deletions

View File

@@ -67,8 +67,9 @@ internal class TaskExecutor(private val cs: CoroutineScope) {
} ?: emptyMap()
psiFile.children.filterIsInstance<PyImportStatementBase>().mapNotNull { import ->
import.importElements.firstNotNullOfOrNull { it.importedQName?.firstComponent }?.let { firstModule ->
val packageName = PyPsiPackageUtil.moduleToPackageName(firstModule)
// all imports from the same statement should start with the same module
import.fullyQualifiedObjectNames.firstOrNull()?.let { firstModule ->
val packageName = PyPsiPackageUtil.moduleToPackageName(firstModule.split('.').first())
PackageUsage(
name = packageName,
version = packages2Versions[packageName] ?: "0.0",

View File

@@ -12,7 +12,7 @@ class PyPackageInEditorUsageCollector : ProjectUsagesCollector() {
val keys = PyPackageUsageStatistics.getInstance(project).getStatisticsAndResetState().keys
return keys.map { packageUsage ->
PYTHON_PACKAGES_IN_EDITOR.metric(PACKAGE_FIELD.with(packageUsage.name),
PACKAGE_VERSION_FIELD.with(packageUsage.name),
PACKAGE_VERSION_FIELD.with(packageUsage.version),
INTERPRETER_TYPE.with(packageUsage.interpreterTypeValue),
EXECUTION_TYPE.with(packageUsage.targetTypeValue),
HAS_SDK.with(packageUsage.hasSdk!!)