mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-21474 Fixed: Type checking confused by None default argument
PyTypeAssertionEvaluator: Mark reference which is used as condition in PyConditionalExpression as non-None
This commit is contained in:
@@ -1504,6 +1504,16 @@ public class PyTypeTest extends PyTestCase {
|
||||
"expr = foo(a=1, b=\"2\")");
|
||||
}
|
||||
|
||||
// PY-21474
|
||||
public void testReassigningOptionalListWithDefaultValue() {
|
||||
doTest("Union[List[str], list]",
|
||||
"def x(things):\n" +
|
||||
" \"\"\"\n" +
|
||||
" :type things: None | list[str]\n" +
|
||||
" \"\"\"\n" +
|
||||
" expr = things if things else []");
|
||||
}
|
||||
|
||||
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