From 53a7528022427254923019779c0bb82da97cf62a Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 4 Jun 2025 14:46:47 +0200 Subject: [PATCH] [python] Use `Any` in place of unresolved `object` (PyTypeHintsInspection.kt) GitOrigin-RevId: 701463ca2d95e6483f9ca640dcf39e173e47c0c3 --- .../jetbrains/python/inspections/PyTypeHintsInspection.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 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 f8f0b087926a..b01746fbbdfd 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 @@ -126,8 +126,7 @@ class PyTypeHintsInspection : PyInspection() { } override fun visitPyTypeParameter(typeParameter: PyTypeParameter) { - val defaultExpression = typeParameter.defaultExpression - if (defaultExpression == null) return + val defaultExpression = typeParameter.defaultExpression ?: return when(typeParameter.kind) { PyAstTypeParameter.Kind.TypeVar -> { val typeVarType = PyTypingTypeProvider.getTypeParameterTypeFromTypeParameter(typeParameter, myTypeEvalContext) as? PyTypeVarType @@ -1439,8 +1438,7 @@ class PyTypeHintsInspection : PyInspection() { private fun validateTypeVarDefaultType(typeVarType: PyTypeVarType, defaultType: PyType?, defaultExpression: PyExpression) { val defaultTypes = when (defaultType) { is PyTypeVarType -> defaultType.constraints.ifEmpty { - val objectType = PyBuiltinCache.getInstance(defaultExpression).objectType ?: return - listOf(defaultType.bound ?: objectType) + listOf(defaultType.bound ?: PyBuiltinCache.getInstance(defaultExpression).objectType) } else -> listOf(defaultType) }