mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-20757 Fixed: Incorrect warning about expected attribute
Make min skeletons generic.
This commit is contained in:
committed by
Semyon Proshev
parent
a77aed6035
commit
c58302f45c
@@ -209,6 +209,16 @@ def map(function, sequence, *sequence_1):
|
||||
pass
|
||||
|
||||
|
||||
def min(*args, key=None, default=None):
|
||||
"""Return the smallest item in an iterable or the smallest of two or more
|
||||
arguments.
|
||||
|
||||
:type args: tuple[T]
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def next(iterator, default=None):
|
||||
"""Return the next item from the iterator.
|
||||
|
||||
|
||||
@@ -225,7 +225,8 @@ def min(*args, key=None, default=None):
|
||||
"""Return the smallest item in an iterable or the smallest of two or more
|
||||
arguments.
|
||||
|
||||
:rtype: object | unknown
|
||||
:type args: tuple[T]
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -448,6 +448,17 @@ public class Py3TypeTest extends PyTestCase {
|
||||
" expr = x");
|
||||
}
|
||||
|
||||
// PY-20757
|
||||
public void testMinElseNone() {
|
||||
doTest("Union[None, Any]",
|
||||
"def get_value(v):\n" +
|
||||
" if v:\n" +
|
||||
" return min(v)\n" +
|
||||
" else:\n" +
|
||||
" return None\n" +
|
||||
"expr = get_value([])");
|
||||
}
|
||||
|
||||
private void doTest(final String expectedType, final String text) {
|
||||
myFixture.configureByText(PythonFileType.INSTANCE, text);
|
||||
final PyExpression expr = myFixture.findElementByText("expr", PyExpression.class);
|
||||
|
||||
@@ -1398,6 +1398,17 @@ public class PyTypeTest extends PyTestCase {
|
||||
"expr = float.fromhex(\"0.5\")");
|
||||
}
|
||||
|
||||
// PY-20757
|
||||
public void testMinOrNone() {
|
||||
doTest("Union[None, Any]",
|
||||
"def get_value(v):\n" +
|
||||
" if v:\n" +
|
||||
" return min(v)\n" +
|
||||
" else:\n" +
|
||||
" return None\n" +
|
||||
"expr = get_value([])");
|
||||
}
|
||||
|
||||
private static List<TypeEvalContext> getTypeEvalContexts(@NotNull PyExpression element) {
|
||||
return ImmutableList.of(TypeEvalContext.codeAnalysis(element.getProject(), element.getContainingFile()).withTracing(),
|
||||
TypeEvalContext.userInitiated(element.getProject(), element.getContainingFile()).withTracing());
|
||||
|
||||
Reference in New Issue
Block a user