mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-82818 PyCharm infers None for dict.get(..., None) if dict key/value types are unknown
GitOrigin-RevId: d12ed4598d91f1ab4824f6e5953e275672027064
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ab81c86fe5
commit
039326217e
@@ -18,6 +18,37 @@ import java.util.Map;
|
||||
public class Py3TypeTest extends PyTestCase {
|
||||
public static final String TEST_DIRECTORY = "/types/";
|
||||
|
||||
/**
|
||||
Overload signatures for dict.get and dict.pop in builtins.pyi differ slightly,
|
||||
dict.get has default value for "default" parameter. This affect the logic of overload resolution.
|
||||
Therefore it makes sense to test both.
|
||||
<p>
|
||||
<pre>{@code
|
||||
@overload
|
||||
def get(self, key: _KT, default: None = None, /) -> _VT | None: ...
|
||||
# mode overloads...
|
||||
}</pre>
|
||||
<p>
|
||||
<pre>{@code
|
||||
@overload
|
||||
def pop(self, key: _KT, /) -> _VT: ...
|
||||
# mode overloads...
|
||||
}</pre>
|
||||
*/
|
||||
// PY-82818
|
||||
public void testGetFromDictWithDefaultNoneValue() {
|
||||
doTest("Any | None", """
|
||||
d = {}
|
||||
expr = d.get("abc", None)""");
|
||||
}
|
||||
|
||||
// PY-82818
|
||||
public void testPopFromDictWithDefaultNoneValue() {
|
||||
doTest("Any", """
|
||||
d = {}
|
||||
expr = d.pop("abc", None)""");
|
||||
}
|
||||
|
||||
public void testYieldInsideLambda() {
|
||||
// Checks that foo is not a generator
|
||||
doTest("int", """
|
||||
|
||||
@@ -1775,7 +1775,7 @@ public class PyTypeTest extends PyTestCase {
|
||||
|
||||
// PY-20409
|
||||
public void testGetFromDictWithDefaultNoneValue() {
|
||||
doTest("Optional[Any]",
|
||||
doTest("Any",
|
||||
"d = {}\n" +
|
||||
"expr = d.get(\"abc\", None)");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user