Commit da8aa6a
authored
[ty] Support iterating over enums (#19486)
## Summary
Infer the correct type in a scenario like this:
```py
class Color(Enum):
RED = 1
GREEN = 2
BLUE = 3
for color in Color:
reveal_type(color) # revealed: Color
```
We should eventually support this out-of-the-box when
astral-sh/ty#501 is implemented. For this
reason, @AlexWaygood would prefer to keep things as they are (we
currently infer `Unknown`, so false positives seem unlikely). But it
seemed relatively easy to support, so I'm opening this for discussion.
part of astral-sh/ty#183
## Test Plan
Adapted existing test.
## Ecosystem analysis
```diff
- warning[unused-ignore-comment] rotkehlchen/chain/aggregator.py:591:82: Unused blanket `type: ignore` directive
```
This `unused-ignore-comment` goes away due to a new true positive.1 parent ee69d38 commit da8aa6a
3 files changed
Lines changed: 26 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
410 | | - | |
| 409 | + | |
411 | 410 | | |
412 | 411 | | |
413 | 412 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
560 | 561 | | |
561 | 562 | | |
562 | 563 | | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
563 | 577 | | |
564 | 578 | | |
565 | 579 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2564 | 2564 | | |
2565 | 2565 | | |
2566 | 2566 | | |
| 2567 | + | |
2567 | 2568 | | |
2568 | 2569 | | |
2569 | 2570 | | |
| |||
2660 | 2661 | | |
2661 | 2662 | | |
2662 | 2663 | | |
| 2664 | + | |
2663 | 2665 | | |
2664 | 2666 | | |
2665 | 2667 | | |
| |||
2753 | 2755 | | |
2754 | 2756 | | |
2755 | 2757 | | |
| 2758 | + | |
2756 | 2759 | | |
2757 | 2760 | | |
2758 | 2761 | | |
| |||
2814 | 2817 | | |
2815 | 2818 | | |
2816 | 2819 | | |
| 2820 | + | |
2817 | 2821 | | |
2818 | 2822 | | |
2819 | 2823 | | |
| |||
2842 | 2846 | | |
2843 | 2847 | | |
2844 | 2848 | | |
2845 | | - | |
| 2849 | + | |
2846 | 2850 | | |
2847 | 2851 | | |
2848 | 2852 | | |
| |||
2968 | 2972 | | |
2969 | 2973 | | |
2970 | 2974 | | |
| 2975 | + | |
2971 | 2976 | | |
2972 | 2977 | | |
2973 | 2978 | | |
| |||
3203 | 3208 | | |
3204 | 3209 | | |
3205 | 3210 | | |
| 3211 | + | |
3206 | 3212 | | |
3207 | 3213 | | |
3208 | 3214 | | |
| |||
3311 | 3317 | | |
3312 | 3318 | | |
3313 | 3319 | | |
| 3320 | + | |
3314 | 3321 | | |
3315 | 3322 | | |
3316 | 3323 | | |
| |||
3384 | 3391 | | |
3385 | 3392 | | |
3386 | 3393 | | |
| 3394 | + | |
3387 | 3395 | | |
3388 | 3396 | | |
3389 | 3397 | | |
| |||
3435 | 3443 | | |
3436 | 3444 | | |
3437 | 3445 | | |
| 3446 | + | |
3438 | 3447 | | |
3439 | 3448 | | |
3440 | 3449 | | |
| |||
3538 | 3547 | | |
3539 | 3548 | | |
3540 | 3549 | | |
| 3550 | + | |
3541 | 3551 | | |
3542 | 3552 | | |
3543 | 3553 | | |
| |||
0 commit comments