@@ -181,6 +181,16 @@ def generate_strict_asymmetric_cases():
181181 pytest .param (bool , int , id = "different-primitives" ),
182182 pytest .param ((Literal ["a" , "b" ]), (Literal ["a" , "b" , "c" ]), id = "sending-subset-literal" ),
183183 pytest .param ((Literal ["b" , "c" ]), (Literal ["a" , "b" , "c" ]), id = "sending-non-prefix-subset-literal" ),
184+ pytest .param (Literal ["a" , "b" ], str , id = "string-literal-to-str" ),
185+ pytest .param (Literal [1 , 2 ], int , id = "int-literal-to-int" ),
186+ pytest .param (Literal [Enum1 .TEST1 ], Enum1 , id = "enum-literal-to-enum" ),
187+ pytest .param (Literal ["a" ], str | None , id = "string-literal-to-optional-str-pep604" ),
188+ pytest .param (Literal ["a" ], Optional [str ], id = "string-literal-to-optional-str" ),
189+ pytest .param (Literal [1 , "a" ], Union [int , str ], id = "mixed-literal-to-typing-union-of-value-types" ),
190+ pytest .param (Literal [None ], str | None , id = "none-literal-to-optional-str" ),
191+ pytest .param (Literal [1 , "a" ], int | str , id = "mixed-literal-to-union-of-value-types" ),
192+ pytest .param (Literal ["a" , 1 ], Literal ["a" ] | int , id = "mixed-literal-to-union-of-literal-and-type" ),
193+ pytest .param (list [Literal ["a" ]], list [str ], id = "list-of-string-literal-to-list-of-str" ),
184194 pytest .param ((Optional [str ]), (Union [int , str , None ]), id = "union-to-superset-union-in-other-order" ),
185195 pytest .param (str | None , str | int | None , id = "union-to-superset-union-in-other-order-pep604" ),
186196 pytest .param (
@@ -554,6 +564,9 @@ def test_list_and_iterable_are_not_compatible_strict(sender_type, receiver_type)
554564 pytest .param ((Literal ["a" , "b" , "c" ]), (Literal ["x" , "y" ]), id = "different-literal-of-same-primitive" ),
555565 pytest .param ((Literal ["a" , "x" ]), (Literal ["a" , "b" , "c" ]), id = "partially-overlapping-literals" ),
556566 pytest .param ((Literal [Enum1 .TEST1 ]), (Literal [Enum1 .TEST2 ]), id = "different-literal-of-same-enum" ),
567+ pytest .param (Literal ["a" ], int , id = "string-literal-to-different-primitive" ),
568+ pytest .param (Literal [1 , "a" ], int , id = "mixed-literal-to-type-of-some-values" ),
569+ pytest .param (Literal ["a" , "x" ], Literal ["a" ] | int , id = "literal-partially-matching-union-of-literal-and-type" ),
557570 pytest .param (
558571 (List [Set [Sequence [str ]]]), (List [Set [Sequence [bool ]]]), id = "nested-sequences-of-different-primitives"
559572 ),
@@ -1031,6 +1044,9 @@ def test_types_are_compatible_with_conversion(self):
10311044
10321045 assert _types_are_compatible (sender = str , receiver = List [str ]) == (True , ConversionStrategy .WRAP )
10331046 assert _types_are_compatible (sender = str , receiver = list [str ]) == (True , ConversionStrategy .WRAP )
1047+ assert _types_are_compatible (sender = Literal ["a" ], receiver = list [str ]) == (True , ConversionStrategy .WRAP )
1048+ assert _types_are_compatible (sender = Literal ["a" , "b" ], receiver = List [str ]) == (True , ConversionStrategy .WRAP )
1049+ assert _types_are_compatible (sender = Literal ["a" ], receiver = list [int ]) == (False , None )
10341050
10351051 assert _types_are_compatible (sender = ChatMessage , receiver = List [str ]) == (
10361052 True ,
0 commit comments