Skip to content

Commit 1cef6e5

Browse files
authored
Adding test-case
1 parent 9546eee commit 1cef6e5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Lib/test/test_annotationlib.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,17 @@ def g(
393393
"z": "a[(int, str), 5]",
394394
},
395395
)
396+
397+
def test_set_ordering_consistency(self):
398+
"""Test that sets of types are consistently ordered in string representations."""
399+
# Test with direct set annotations
400+
def g1(x: {int, str}):
401+
pass
402+
403+
anno_g1 = get_annotations(g1, format=Format.STRING)
404+
405+
# The set should have elements sorted by name (int before str)
406+
self.assertEqual(anno_g1["x"], "{int, str}")
396407

397408
def test_nested_expressions(self):
398409
def f(

0 commit comments

Comments
 (0)