Skip to content

Commit 9c75262

Browse files
missingdaysintellij-monorepo-bot
authored andcommitted
refactor pycharm: Extract "typing.Iterable" string to PyTypingTypeProvider.ITERABLE
(cherry picked from commit cc99d3cfe0d71c55fc01acc69d0016ed524da6e9) GitOrigin-RevId: 3d54a69c6b99b569d760ce7c606efb54e220459c
1 parent 587cdcf commit 9c75262

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

python/python-psi-impl/src/com/jetbrains/python/codeInsight/typing/PyTypingTypeProvider.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ class PyTypingTypeProvider : PyTypeProviderWithCustomContext<Context?>() {
733733
const val NOT_REQUIRED_EXT: String = "typing_extensions.NotRequired"
734734
const val READONLY: String = "typing.ReadOnly"
735735
const val READONLY_EXT: String = "typing_extensions.ReadOnly"
736+
const val ITERABLE: String = "typing.Iterable"
736737

737738
val TYPE_PARAMETER_FACTORIES: Set<String> = setOf(
738739
TYPE_VAR, TYPE_VAR_EXT,

python/python-psi-impl/src/com/jetbrains/python/psi/types/PyCollectionTypeImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.intellij.openapi.util.text.StringUtil;
2020
import com.intellij.psi.PsiElement;
2121
import com.intellij.util.containers.ContainerUtil;
22+
import com.jetbrains.python.codeInsight.typing.PyTypingTypeProvider;
2223
import com.jetbrains.python.psi.PyCallSiteExpression;
2324
import com.jetbrains.python.psi.PyClass;
2425
import com.jetbrains.python.psi.PyPsiFacade;
@@ -109,10 +110,9 @@ public int hashCode() {
109110
@Override
110111
public @Nullable PyType getIteratedItemType() {
111112
if (myElementTypes.size() >= 2) {
112-
String iterableName = "typing.Iterable";
113-
if (!iterableName.equals(getClassQName())) {
113+
if (!PyTypingTypeProvider.ITERABLE.equals(getClassQName())) {
114114
TypeEvalContext context = TypeEvalContext.codeInsightFallback(getPyClass().getProject());
115-
PyType asIterable = PyTypeUtil.convertToType(this, iterableName, getPyClass(), context);
115+
PyType asIterable = PyTypeUtil.convertToType(this, PyTypingTypeProvider.ITERABLE, getPyClass(), context);
116116
if (asIterable instanceof PyCollectionType collectionType) {
117117
return collectionType.getIteratedItemType();
118118
}

0 commit comments

Comments
 (0)