Skip to content

Commit 881ffee

Browse files
committed
+1 test and formatting
1 parent 8cc4464 commit 881ffee

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/test_typing_extensions.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,39 +1650,43 @@ def test_annotation_and_optional_default(self):
16501650
optional_annotation = Optional[annotation]
16511651

16521652
cases = {
1653+
# (annotation, none_default) : expected_type_hints
16531654
((), False): {},
16541655
((), True): {},
1655-
(int, False): {"x": int},
1656-
(int, True): {"x": int},
1657-
(Optional[int], False): {"x": Optional[int]},
1658-
(Optional[int], True): {"x": Optional[int]},
1659-
(optional_annotation, False): {"x": optional_annotation},
1660-
(optional_annotation, True): {"x": optional_annotation},
1661-
(str(optional_annotation), True): {"x": optional_annotation},
1662-
(annotation, False): {"x": annotation},
1663-
(annotation, True): {"x": annotation},
1664-
(Union[annotation, T], False): {"x": Union[annotation, T]},
1665-
(Union[annotation, T], True): {"x": Union[annotation, T]},
1666-
(Union[str, None, "str"], False): {"x": Optional[str]},
1667-
(Union[str, None, "str"], True): {"x": Optional[str]},
1656+
(int, False): {'x': int},
1657+
(int, True): {'x': int},
1658+
(Optional[int], False): {'x': Optional[int]},
1659+
(Optional[int], True): {'x': Optional[int]},
1660+
(optional_annotation, False): {'x': optional_annotation},
1661+
(optional_annotation, True): {'x': optional_annotation},
1662+
(str(optional_annotation), True): {'x': optional_annotation},
1663+
(annotation, False): {'x': annotation},
1664+
(annotation, True): {'x': annotation},
1665+
(Union[annotation, T], False): {'x': Union[annotation, T]},
1666+
(Union[annotation, T], True): {'x': Union[annotation, T]},
1667+
("Union[Annotated[Union[int, None], 'data'], T]", True): {
1668+
'x': Union[annotation, T]
1669+
},
1670+
(Union[str, None, "str"], False): {'x': Optional[str]},
1671+
(Union[str, None, "str"], True): {'x': Optional[str]},
16681672
(Union[str, "str"], False): {
1669-
"x": str
1673+
'x': str
16701674
if sys.version_info >= (3, 9)
16711675
# _eval_type does not resolve correctly to str in 3.8
16721676
else typing._eval_type(Union[str, "str"], None, None),
16731677
},
1674-
(Union[str, "str"], True): {"x": str},
1675-
(List["str"], False): {"x": List[str]},
1676-
(List["str"], True): {"x": List[str]},
1677-
(Optional[List[str]], False): {"x": Optional[List[str]]},
1678-
(Optional[List[str]], True): {"x": Optional[List[str]]},
1678+
(Union[str, "str"], True): {'x': str},
1679+
(List["str"], False): {'x': List[str]},
1680+
(List["str"], True): {'x': List[str]},
1681+
(Optional[List[str]], False): {'x': Optional[List[str]]},
1682+
(Optional[List[str]], True): {'x': Optional[List[str]]},
16791683
}
16801684

16811685
for (annot, none_default), expected in cases.items():
16821686
with self.subTest(annotation=annot, none_default=none_default, expected_type_hints=expected):
16831687
if annot == ():
16841688
if none_default:
1685-
def func(x = None): pass
1689+
def func(x=None): pass
16861690
else:
16871691
def func(x): pass
16881692
elif none_default:

0 commit comments

Comments
 (0)