mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[python] fix builtins.callable
Merge-request: IJ-MR-177060 Merged-by: Morgan Bartholomew <morgan.bartholomew@jetbrains.com> GitOrigin-RevId: 2ec5c5ea1cc4183d757351f051b914a456ff15d8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f02d90ff7c
commit
eafca8d96d
-6
@@ -50,12 +50,6 @@ public class PyTypeAssertionEvaluator extends PyRecursiveElementVisitor {
|
||||
transformTypeFromAssertion(context.getType(typeElement), false, context, typeElement));
|
||||
}
|
||||
}
|
||||
else if (node.isCalleeText(PyNames.CALLABLE_BUILTIN)) {
|
||||
final PyExpression[] args = node.getArguments();
|
||||
if (args.length == 1) {
|
||||
pushAssertion(args[0], myPositive, context -> PyTypingTypeProvider.createTypingCallableType(node));
|
||||
}
|
||||
}
|
||||
else if (node.isCalleeText(PyNames.ISSUBCLASS)) {
|
||||
final PyExpression[] args = node.getArguments();
|
||||
if (args.length == 2) {
|
||||
|
||||
@@ -4161,6 +4161,15 @@ public class Py3TypeTest extends PyTestCase {
|
||||
""");
|
||||
}
|
||||
|
||||
@TestFor(issues="PY-84524")
|
||||
public void testBuiltinsCallable() {
|
||||
doTest("(...) -> object", """
|
||||
a = object()
|
||||
if callable(a):
|
||||
expr = a
|
||||
""");
|
||||
}
|
||||
|
||||
private void doTest(final String expectedType, final String text) {
|
||||
myFixture.configureByText(PythonFileType.INSTANCE, text);
|
||||
final PyExpression expr = myFixture.findElementByText("expr", PyExpression.class);
|
||||
|
||||
@@ -1980,7 +1980,9 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-79861
|
||||
public void testWalrusCallable() {
|
||||
doTest("type[Callable]",
|
||||
// should actually be `(...) -> object` ... should actually be `Literal[42] & (...) -> object ... should actually be `Never`
|
||||
// but we don't support this case yet
|
||||
doTest("int",
|
||||
"""
|
||||
if callable(a := 42):
|
||||
expr = a""");
|
||||
|
||||
Reference in New Issue
Block a user