diff options
Diffstat (limited to 'python/src/com/jetbrains/python/inspections')
-rw-r--r-- | python/src/com/jetbrains/python/inspections/PyStringFormatInspection.java | 5 | ||||
-rw-r--r-- | python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/python/src/com/jetbrains/python/inspections/PyStringFormatInspection.java b/python/src/com/jetbrains/python/inspections/PyStringFormatInspection.java index 162fa0b9bc60..40efca3663a0 100644 --- a/python/src/com/jetbrains/python/inspections/PyStringFormatInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyStringFormatInspection.java @@ -41,6 +41,7 @@ import java.util.Map; import static com.jetbrains.python.inspections.PyStringFormatParser.filterSubstitutions; import static com.jetbrains.python.inspections.PyStringFormatParser.parsePercentFormat; +import static com.jetbrains.python.psi.PyUtil.as; /** * @author Alexey.Ivanov @@ -416,9 +417,9 @@ public class PyStringFormatInspection extends PyInspection { inspectValues(((PyParenthesizedExpression)rightExpression).getContainedExpression()); } else { - final PyType type = myTypeEvalContext.getType(rightExpression); + final PyClassType type = as(myTypeEvalContext.getType(rightExpression), PyClassType.class); if (type != null) { - if (myUsedMappingKeys.size() > 0 && !("dict".equals(type.getName()))) { + if (myUsedMappingKeys.size() > 0 && !PyABCUtil.isSubclass(type.getPyClass(), PyNames.MAPPING)) { registerProblem(rightExpression, PyBundle.message("INSP.format.requires.mapping")); return; } diff --git a/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java b/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java index c0fb3c1d620d..4fd58629c516 100644 --- a/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java +++ b/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java @@ -69,7 +69,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.*; -import java.util.HashSet; import static com.jetbrains.python.inspections.quickfix.AddIgnoredIdentifierQuickFix.END_WILDCARD; @@ -833,6 +832,9 @@ public class PyUnresolvedReferencesInspection extends PyInspection { else { actions.add(importFix); } + if (ScopeUtil.getScopeOwner(node) instanceof PyFunction) { + actions.add(importFix.forLocalImport()); + } } } |