@@ -588,3 +588,45 @@ class S:
588
588
'{:%}'.format(0.001)
589
589
[builtins fixtures/primitives.pyi]
590
590
[typing fixtures/typing-medium.pyi]
591
+
592
+ [case testEnumWithStringToFormatValue]
593
+ from enum import Enum
594
+
595
+ class Responses(str, Enum):
596
+ TEMPLATED = 'insert {} here'
597
+ TEMPLATED_WITH_KW = 'insert {value} here'
598
+ NORMAL = 'something'
599
+
600
+ Responses.TEMPLATED.format(42)
601
+ Responses.TEMPLATED_WITH_KW.format(value=42)
602
+ Responses.TEMPLATED.format() # E: Cannot find replacement for positional format specifier 0
603
+ Responses.TEMPLATED_WITH_KW.format() # E: Cannot find replacement for named format specifier "value"
604
+ Responses.NORMAL.format(42) # E: Not all arguments converted during string formatting
605
+ Responses.NORMAL.format(value=42) # E: Not all arguments converted during string formatting
606
+ [builtins fixtures/primitives.pyi]
607
+
608
+ [case testNonStringEnumToFormatValue]
609
+ from enum import Enum
610
+
611
+ class Responses(Enum):
612
+ TEMPLATED = 'insert {value} here'
613
+
614
+ Responses.TEMPLATED.format(value=42) # E: "Responses" has no attribute "format"
615
+ [builtins fixtures/primitives.pyi]
616
+
617
+ [case testStrEnumWithStringToFormatValue]
618
+ # flags: --python-version 3.11
619
+ from enum import StrEnum
620
+
621
+ class Responses(StrEnum):
622
+ TEMPLATED = 'insert {} here'
623
+ TEMPLATED_WITH_KW = 'insert {value} here'
624
+ NORMAL = 'something'
625
+
626
+ Responses.TEMPLATED.format(42)
627
+ Responses.TEMPLATED_WITH_KW.format(value=42)
628
+ Responses.TEMPLATED.format() # E: Cannot find replacement for positional format specifier 0
629
+ Responses.TEMPLATED_WITH_KW.format() # E: Cannot find replacement for named format specifier "value"
630
+ Responses.NORMAL.format(42) # E: Not all arguments converted during string formatting
631
+ Responses.NORMAL.format(value=42) # E: Not all arguments converted during string formatting
632
+ [builtins fixtures/primitives.pyi]
0 commit comments