From 126b58d09964c143b58c7924cd9a080c0e4b3173 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Fri, 29 Mar 2024 20:47:52 +0200 Subject: [PATCH] [python] Cleanup in ImportToImportFromIntention: remove redundant casts GitOrigin-RevId: 28ba26e6c199d57052bab81f32a9b20e1a990ff2 --- .../intentions/ImportToImportFromIntention.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/intentions/ImportToImportFromIntention.java b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/intentions/ImportToImportFromIntention.java index 8bae898e4785..a3c9b9aded59 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/intentions/ImportToImportFromIntention.java +++ b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/intentions/ImportToImportFromIntention.java @@ -130,15 +130,15 @@ public final class ImportToImportFromIntention extends PsiBasedModCommandAction< // create a separate import stmt for the module final PsiElement importer = myImportElement.getParent(); - final PyStatement importStatement; + final PyImportStatementBase importStatement; final PyImportElement[] importElements; - if (importer instanceof PyImportStatement) { - importStatement = (PyImportStatement)importer; - importElements = ((PyImportStatement)importStatement).getImportElements(); + if (importer instanceof PyImportStatement qualifiedImportStatement) { + importStatement = qualifiedImportStatement; + importElements = importStatement.getImportElements(); } - else if (importer instanceof PyFromImportStatement) { - importStatement = (PyFromImportStatement)importer; - importElements = ((PyFromImportStatement)importStatement).getImportElements(); + else if (importer instanceof PyFromImportStatement fromImportStatement) { + importStatement = fromImportStatement; + importElements = importStatement.getImportElements(); } else { throw new IncorrectOperationException("Not an import at all");