Commit 248e1fd
committed
Add config option to disable
Summary
--
This PR resolves #9761 by adding a linter configuration option to disable
`typing_extensions` imports. As mentioned [here], it would be ideal if we could
detect whether or not `typing_extensions` is available as a dependency
automatically, but this seems like a much easier fix in the meantime.
The default for the new option `disable-typing-extensions` is `false`,
preserving the current behavior. Setting it to `true` will bail out of the new
`Checker::import_from_typing` method (#17340) with a new
`TypingImportError::TypingExtensionsDisabled` error, which should log an
explanatory message whenever `Diagnostic::try_set_fix` is used.
[here]: #9761 (comment)
Test Plan
--
New linter tests exercising several combinations of Python versions and the new
config option for PYI019. We could also test other rules, but any rule using
`import_from_typing` should behave the same way.typing_extensions imports1 parent 3872d57 commit 248e1fd
12 files changed
Lines changed: 230 additions & 34 deletions
File tree
- crates
- ruff_linter/src
- checkers/ast
- settings
- snapshots
- ruff_workspace/src
- ruff/tests
- snapshots
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
994 | 994 | | |
995 | 995 | | |
996 | 996 | | |
| 997 | + | |
997 | 998 | | |
998 | 999 | | |
999 | 1000 | | |
| |||
2117 | 2118 | | |
2118 | 2119 | | |
2119 | 2120 | | |
2120 | | - | |
| 2121 | + | |
2121 | 2122 | | |
2122 | 2123 | | |
2123 | 2124 | | |
| |||
2207 | 2208 | | |
2208 | 2209 | | |
2209 | 2210 | | |
| 2211 | + | |
2210 | 2212 | | |
2211 | 2213 | | |
2212 | 2214 | | |
| |||
2390 | 2392 | | |
2391 | 2393 | | |
2392 | 2394 | | |
2393 | | - | |
| 2395 | + | |
2394 | 2396 | | |
2395 | 2397 | | |
2396 | 2398 | | |
| |||
2428 | 2430 | | |
2429 | 2431 | | |
2430 | 2432 | | |
2431 | | - | |
| 2433 | + | |
2432 | 2434 | | |
2433 | 2435 | | |
2434 | 2436 | | |
| |||
2518 | 2520 | | |
2519 | 2521 | | |
2520 | 2522 | | |
| 2523 | + | |
2521 | 2524 | | |
2522 | 2525 | | |
2523 | 2526 | | |
| |||
2701 | 2704 | | |
2702 | 2705 | | |
2703 | 2706 | | |
2704 | | - | |
| 2707 | + | |
2705 | 2708 | | |
2706 | 2709 | | |
2707 | 2710 | | |
| |||
2790 | 2793 | | |
2791 | 2794 | | |
2792 | 2795 | | |
2793 | | - | |
| 2796 | + | |
2794 | 2797 | | |
2795 | 2798 | | |
2796 | 2799 | | |
| |||
2881 | 2884 | | |
2882 | 2885 | | |
2883 | 2886 | | |
| 2887 | + | |
2884 | 2888 | | |
2885 | 2889 | | |
2886 | 2890 | | |
| |||
3064 | 3068 | | |
3065 | 3069 | | |
3066 | 3070 | | |
3067 | | - | |
| 3071 | + | |
3068 | 3072 | | |
3069 | 3073 | | |
3070 | 3074 | | |
| |||
3170 | 3174 | | |
3171 | 3175 | | |
3172 | 3176 | | |
3173 | | - | |
| 3177 | + | |
3174 | 3178 | | |
3175 | 3179 | | |
3176 | 3180 | | |
| |||
3260 | 3264 | | |
3261 | 3265 | | |
3262 | 3266 | | |
| 3267 | + | |
3263 | 3268 | | |
3264 | 3269 | | |
3265 | 3270 | | |
| |||
3443 | 3448 | | |
3444 | 3449 | | |
3445 | 3450 | | |
3446 | | - | |
| 3451 | + | |
3447 | 3452 | | |
3448 | 3453 | | |
3449 | 3454 | | |
| |||
3497 | 3502 | | |
3498 | 3503 | | |
3499 | 3504 | | |
3500 | | - | |
| 3505 | + | |
3501 | 3506 | | |
3502 | 3507 | | |
3503 | 3508 | | |
| |||
3587 | 3592 | | |
3588 | 3593 | | |
3589 | 3594 | | |
| 3595 | + | |
3590 | 3596 | | |
3591 | 3597 | | |
3592 | 3598 | | |
| |||
3770 | 3776 | | |
3771 | 3777 | | |
3772 | 3778 | | |
3773 | | - | |
| 3779 | + | |
3774 | 3780 | | |
3775 | 3781 | | |
3776 | 3782 | | |
| |||
3823 | 3829 | | |
3824 | 3830 | | |
3825 | 3831 | | |
3826 | | - | |
| 3832 | + | |
3827 | 3833 | | |
3828 | 3834 | | |
3829 | 3835 | | |
| |||
3914 | 3920 | | |
3915 | 3921 | | |
3916 | 3922 | | |
| 3923 | + | |
3917 | 3924 | | |
3918 | 3925 | | |
3919 | 3926 | | |
| |||
4097 | 4104 | | |
4098 | 4105 | | |
4099 | 4106 | | |
4100 | | - | |
| 4107 | + | |
4101 | 4108 | | |
4102 | 4109 | | |
4103 | 4110 | | |
| |||
4107 | 4114 | | |
4108 | 4115 | | |
4109 | 4116 | | |
4110 | | - | |
| 4117 | + | |
4111 | 4118 | | |
4112 | 4119 | | |
4113 | 4120 | | |
| |||
4198 | 4205 | | |
4199 | 4206 | | |
4200 | 4207 | | |
| 4208 | + | |
4201 | 4209 | | |
4202 | 4210 | | |
4203 | 4211 | | |
| |||
4381 | 4389 | | |
4382 | 4390 | | |
4383 | 4391 | | |
4384 | | - | |
| 4392 | + | |
4385 | 4393 | | |
4386 | 4394 | | |
4387 | 4395 | | |
| |||
4444 | 4452 | | |
4445 | 4453 | | |
4446 | 4454 | | |
4447 | | - | |
| 4455 | + | |
4448 | 4456 | | |
4449 | 4457 | | |
4450 | 4458 | | |
| |||
4535 | 4543 | | |
4536 | 4544 | | |
4537 | 4545 | | |
| 4546 | + | |
4538 | 4547 | | |
4539 | 4548 | | |
4540 | 4549 | | |
| |||
4718 | 4727 | | |
4719 | 4728 | | |
4720 | 4729 | | |
4721 | | - | |
| 4730 | + | |
4722 | 4731 | | |
4723 | 4732 | | |
4724 | 4733 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
216 | 217 | | |
217 | 218 | | |
218 | 219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
544 | 544 | | |
545 | 545 | | |
546 | 546 | | |
547 | | - | |
| 547 | + | |
548 | 548 | | |
549 | 549 | | |
| 550 | + | |
| 551 | + | |
550 | 552 | | |
551 | 553 | | |
552 | 554 | | |
553 | 555 | | |
554 | 556 | | |
555 | 557 | | |
| 558 | + | |
556 | 559 | | |
557 | 560 | | |
558 | 561 | | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
559 | 582 | | |
560 | 583 | | |
561 | 584 | | |
| |||
0 commit comments