Commit af10964
authored
Fix enum value inference with user-defined data type mixin (#16320)
Fixes enum value inference in cases where the value type is of a
user-defined data type class (with `__new__`).
According to https://docs.python.org/3/howto/enum.html#others when
defining an `Enum` subclass with a custom data type:
> A data type is a mixin that defines `__new__()`, or a dataclass
This fixes a regression introduced by #10057 to fix #10000. The `not
ti.fullname.startswith("builtins.")` clause seemed to be intended to
catch enums with a built-in data type like int or bytes, but this is
overly broad. It should allow any type so long as it is not itself an
enum.Enum subclass.1 parent a62a906 commit af10964
2 files changed
Lines changed: 21 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
133 | 137 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1524 | 1524 | | |
1525 | 1525 | | |
1526 | 1526 | | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
1527 | 1542 | | |
1528 | 1543 | | |
1529 | 1544 | | |
| |||
0 commit comments