[python] PY-81424 update message for keyword unpack inspection

GitOrigin-RevId: 24234b4936031a19d08f58fbf871bc1749853745
This commit is contained in:
Morgan Bartholomew
2025-05-26 12:59:37 +10:00
committed by intellij-monorepo-bot
parent 50995c2812
commit 2be8cd044b
3 changed files with 14 additions and 1 deletions

View File

@@ -572,7 +572,7 @@ INSP.parameter(s).unfilled=Parameter(s) unfilled
INSP.incorrect.arguments=Incorrect argument(s)
INSP.possible.callees=Possible callees
INSP.function.lacks.positional.argument=Function ''{0}'' lacks a positional argument
INSP.expected.dict.got.type=Expected a dictionary, got {0}
INSP.expected.dict.got.type=Expected a mapping, got {0}
INSP.expected.iterable.got.type=Expected an iterable, got {0}
# PyMethodParametersInspection

View File

@@ -201,6 +201,7 @@ public final class PyArgumentListInspection extends PyInspection {
if (inside_type != null && !PyTypeChecker.isUnknown(inside_type, context)) {
if (((PyStarArgument)arg).isKeyword()) {
if (!PyABCUtil.isSubtype(inside_type, PyNames.MAPPING, context)) {
// TODO: check that the key type is compatible with `str`
holder.registerProblem(arg, PyPsiBundle.message("INSP.expected.dict.got.type", inside_type.getName()));
}
}

View File

@@ -476,4 +476,16 @@ public class Py3ArgumentListInspectionTest extends PyInspectionTestCase {
c = MyClass(1)
""");
}
public void testKeywordUnpack() {
doTestByText("""
from collections.abc import Mapping
class M(Mapping[str, str]): pass
dict(**M())
dict(<warning descr="Expected a mapping, got int">**1</warning>)
""");
}
}