From 47b67bdbb47b78d615fa4df84c3a96cdb786c884 Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 20 May 2025 17:09:49 +0200 Subject: [PATCH] [python] Slightly simplified code (PyTypeHintsInspection.kt) GitOrigin-RevId: 65179c153ec0f6c2a00ba85a269637bc9fc9aa6f --- .../python/inspections/PyTypeHintsInspection.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/python/python-psi-impl/src/com/jetbrains/python/inspections/PyTypeHintsInspection.kt b/python/python-psi-impl/src/com/jetbrains/python/inspections/PyTypeHintsInspection.kt index 61cbce0677f6..013a3f8a0f56 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/inspections/PyTypeHintsInspection.kt +++ b/python/python-psi-impl/src/com/jetbrains/python/inspections/PyTypeHintsInspection.kt @@ -810,8 +810,8 @@ class PyTypeHintsInspection : PyInspection() { private fun checkGenericCompleteness(cls: PyClass) { var seenGeneric = false - val genericTypeVars = linkedSetOf() - val nonGenericTypeVars = linkedSetOf() + val genericTypeVars = linkedSetOf() + val nonGenericTypeVars = linkedSetOf() cls.superClassExpressions.forEach { superClass -> val generics = collectGenerics(superClass) @@ -827,13 +827,11 @@ class PyTypeHintsInspection : PyInspection() { if (seenGeneric && (nonGenericTypeVars - genericTypeVars).isNotEmpty()) { val nonGenericTypeVarsNames = nonGenericTypeVars .asSequence() - .filterIsInstance() .mapNotNull { it.name } .joinToString(", ") val genericTypeVarsNames = genericTypeVars .asSequence() - .filterIsInstance() .mapNotNull { it.name } .joinToString(", ") @@ -844,14 +842,14 @@ class PyTypeHintsInspection : PyInspection() { } } - private fun collectGenerics(superClassExpression: PyExpression): Pair?, Set> { + private fun collectGenerics(superClassExpression: PyExpression): Pair?, Set> { val resolvedSuperClass = if (superClassExpression is PyReferenceExpression) multiFollowAssignmentsChain(superClassExpression) else listOf(superClassExpression) var seenGeneric = false - val genericTypeVars = linkedSetOf() - val nonGenericTypeVars = linkedSetOf() + val genericTypeVars = linkedSetOf() + val nonGenericTypeVars = linkedSetOf() resolvedSuperClass .asSequence()