Skip to content

Commit f79d833

Browse files
committed
Add test for nested Optional behavior
1 parent fecce0d commit f79d833

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Tests for behavior of nested Optional types collapsing.
3+
4+
Optional[Optional[T]] should behave as Optional[T].
5+
"""
6+
7+
from typing import Optional, assert_type
8+
9+
10+
def test_nested_optional(x: Optional[Optional[int]]) -> None:
11+
# Should behave like Optional[int]
12+
assert_type(x, Optional[int])
13+
14+
15+
def test_nested_optional_error(x: Optional[Optional[int]]) -> int:
16+
return x # E

0 commit comments

Comments
 (0)