Skip to content

Commit 2c8b343

Browse files
migeed-zmeta-codesync[bot]
authored andcommitted
Add testcase to show iter bug in enums
Summary: This is also causing many errors in django as a result Reviewed By: rchen152 Differential Revision: D84173287 fbshipit-source-id: fdf3518f2509f43388cf9ba71b1d5e1c3cc03c3c
1 parent 6fead6c commit 2c8b343

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pyrefly/lib/test/enums.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,3 +568,21 @@ def test(x: EmptyEnum):
568568
assert_type(x.value, Any)
569569
"#,
570570
);
571+
572+
testcase!(
573+
bug = "T_Enum is iterable",
574+
test_enum_iter,
575+
r#"
576+
from enum import Enum
577+
from typing import TypeVar
578+
579+
class MyEnum(Enum):
580+
A = "a"
581+
B = "b"
582+
583+
T_Enum = TypeVar("T_Enum", bound=Enum)
584+
585+
def get_labels(enum_cls: type[T_Enum]) -> list[str]:
586+
return [e.name for e in enum_cls] # E: Type `type[T_Enum]` is not iterable # E: Type `type[T_Enum]` is not iterable
587+
"#,
588+
);

0 commit comments

Comments
 (0)