Skip to content

Commit 401d286

Browse files
MichaReiserGlyphack
authored andcommitted
[ty] Refine message for why a rule is enabled (astral-sh#18038)
1 parent c4443d7 commit 401d286

90 files changed

Lines changed: 184 additions & 181 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

crates/ty/tests/cli.rs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fn config_override_python_version() -> anyhow::Result<()> {
157157
5 | print(sys.last_exc)
158158
| ^^^^^^^^^^^^
159159
|
160-
info: `unresolved-attribute` is enabled by default
160+
info: rule `unresolved-attribute` is enabled by default
161161
162162
Found 1 diagnostic
163163
@@ -296,7 +296,7 @@ fn cli_arguments_are_relative_to_the_current_directory() -> anyhow::Result<()> {
296296
3 |
297297
4 | stat = add(10, 15)
298298
|
299-
info: `unresolved-import` is enabled by default
299+
info: rule `unresolved-import` is enabled by default
300300
301301
Found 1 diagnostic
302302
@@ -400,7 +400,7 @@ fn configuration_rule_severity() -> anyhow::Result<()> {
400400
3 |
401401
4 | for a in range(0, int(y)):
402402
|
403-
info: `division-by-zero` is enabled by default
403+
info: rule `division-by-zero` is enabled by default
404404
405405
error[unresolved-reference]: Name `prin` used when not defined
406406
--> test.py:7:1
@@ -410,7 +410,7 @@ fn configuration_rule_severity() -> anyhow::Result<()> {
410410
7 | prin(x) # unresolved-reference
411411
| ^^^^
412412
|
413-
info: `unresolved-reference` is enabled by default
413+
info: rule `unresolved-reference` is enabled by default
414414
415415
Found 2 diagnostics
416416
@@ -439,7 +439,7 @@ fn configuration_rule_severity() -> anyhow::Result<()> {
439439
3 |
440440
4 | for a in range(0, int(y)):
441441
|
442-
info: `division-by-zero` was selected in the configuration file
442+
info: rule `division-by-zero` was selected in the configuration file
443443
444444
Found 1 diagnostic
445445
@@ -481,7 +481,7 @@ fn cli_rule_severity() -> anyhow::Result<()> {
481481
3 |
482482
4 | y = 4 / 0
483483
|
484-
info: `unresolved-import` is enabled by default
484+
info: rule `unresolved-import` is enabled by default
485485
486486
error[division-by-zero]: Cannot divide object of type `Literal[4]` by zero
487487
--> test.py:4:5
@@ -493,7 +493,7 @@ fn cli_rule_severity() -> anyhow::Result<()> {
493493
5 |
494494
6 | for a in range(0, int(y)):
495495
|
496-
info: `division-by-zero` is enabled by default
496+
info: rule `division-by-zero` is enabled by default
497497
498498
error[unresolved-reference]: Name `prin` used when not defined
499499
--> test.py:9:1
@@ -503,7 +503,7 @@ fn cli_rule_severity() -> anyhow::Result<()> {
503503
9 | prin(x) # unresolved-reference
504504
| ^^^^
505505
|
506-
info: `unresolved-reference` is enabled by default
506+
info: rule `unresolved-reference` is enabled by default
507507
508508
Found 3 diagnostics
509509
@@ -532,7 +532,7 @@ fn cli_rule_severity() -> anyhow::Result<()> {
532532
3 |
533533
4 | y = 4 / 0
534534
|
535-
info: `unresolved-import` was selected on the command line
535+
info: rule `unresolved-import` was selected on the command line
536536
537537
warning[division-by-zero]: Cannot divide object of type `Literal[4]` by zero
538538
--> test.py:4:5
@@ -544,7 +544,7 @@ fn cli_rule_severity() -> anyhow::Result<()> {
544544
5 |
545545
6 | for a in range(0, int(y)):
546546
|
547-
info: `division-by-zero` was selected on the command line
547+
info: rule `division-by-zero` was selected on the command line
548548
549549
Found 2 diagnostics
550550
@@ -586,7 +586,7 @@ fn cli_rule_severity_precedence() -> anyhow::Result<()> {
586586
3 |
587587
4 | for a in range(0, int(y)):
588588
|
589-
info: `division-by-zero` is enabled by default
589+
info: rule `division-by-zero` is enabled by default
590590
591591
error[unresolved-reference]: Name `prin` used when not defined
592592
--> test.py:7:1
@@ -596,7 +596,7 @@ fn cli_rule_severity_precedence() -> anyhow::Result<()> {
596596
7 | prin(x) # unresolved-reference
597597
| ^^^^
598598
|
599-
info: `unresolved-reference` is enabled by default
599+
info: rule `unresolved-reference` is enabled by default
600600
601601
Found 2 diagnostics
602602
@@ -626,7 +626,7 @@ fn cli_rule_severity_precedence() -> anyhow::Result<()> {
626626
3 |
627627
4 | for a in range(0, int(y)):
628628
|
629-
info: `division-by-zero` was selected on the command line
629+
info: rule `division-by-zero` was selected on the command line
630630
631631
Found 1 diagnostic
632632
@@ -707,7 +707,7 @@ fn exit_code_only_warnings() -> anyhow::Result<()> {
707707
1 | print(x) # [unresolved-reference]
708708
| ^
709709
|
710-
info: `unresolved-reference` was selected on the command line
710+
info: rule `unresolved-reference` was selected on the command line
711711
712712
Found 1 diagnostic
713713
@@ -794,7 +794,7 @@ fn exit_code_no_errors_but_error_on_warning_is_true() -> anyhow::Result<()> {
794794
1 | print(x) # [unresolved-reference]
795795
| ^
796796
|
797-
info: `unresolved-reference` was selected on the command line
797+
info: rule `unresolved-reference` was selected on the command line
798798
799799
Found 1 diagnostic
800800
@@ -828,7 +828,7 @@ fn exit_code_no_errors_but_error_on_warning_is_enabled_in_configuration() -> any
828828
1 | print(x) # [unresolved-reference]
829829
| ^
830830
|
831-
info: `unresolved-reference` was selected on the command line
831+
info: rule `unresolved-reference` was selected on the command line
832832
833833
Found 1 diagnostic
834834
@@ -860,7 +860,7 @@ fn exit_code_both_warnings_and_errors() -> anyhow::Result<()> {
860860
| ^
861861
3 | print(4[1]) # [non-subscriptable]
862862
|
863-
info: `unresolved-reference` was selected on the command line
863+
info: rule `unresolved-reference` was selected on the command line
864864
865865
error[non-subscriptable]: Cannot subscript object of type `Literal[4]` with no `__getitem__` method
866866
--> test.py:3:7
@@ -869,7 +869,7 @@ fn exit_code_both_warnings_and_errors() -> anyhow::Result<()> {
869869
3 | print(4[1]) # [non-subscriptable]
870870
| ^
871871
|
872-
info: `non-subscriptable` is enabled by default
872+
info: rule `non-subscriptable` is enabled by default
873873
874874
Found 2 diagnostics
875875
@@ -901,7 +901,7 @@ fn exit_code_both_warnings_and_errors_and_error_on_warning_is_true() -> anyhow::
901901
| ^
902902
3 | print(4[1]) # [non-subscriptable]
903903
|
904-
info: `unresolved-reference` was selected on the command line
904+
info: rule `unresolved-reference` was selected on the command line
905905
906906
error[non-subscriptable]: Cannot subscript object of type `Literal[4]` with no `__getitem__` method
907907
--> test.py:3:7
@@ -910,7 +910,7 @@ fn exit_code_both_warnings_and_errors_and_error_on_warning_is_true() -> anyhow::
910910
3 | print(4[1]) # [non-subscriptable]
911911
| ^
912912
|
913-
info: `non-subscriptable` is enabled by default
913+
info: rule `non-subscriptable` is enabled by default
914914
915915
Found 2 diagnostics
916916
@@ -942,7 +942,7 @@ fn exit_code_exit_zero_is_true() -> anyhow::Result<()> {
942942
| ^
943943
3 | print(4[1]) # [non-subscriptable]
944944
|
945-
info: `unresolved-reference` was selected on the command line
945+
info: rule `unresolved-reference` was selected on the command line
946946
947947
error[non-subscriptable]: Cannot subscript object of type `Literal[4]` with no `__getitem__` method
948948
--> test.py:3:7
@@ -951,7 +951,7 @@ fn exit_code_exit_zero_is_true() -> anyhow::Result<()> {
951951
3 | print(4[1]) # [non-subscriptable]
952952
| ^
953953
|
954-
info: `non-subscriptable` is enabled by default
954+
info: rule `non-subscriptable` is enabled by default
955955
956956
Found 2 diagnostics
957957
@@ -1006,7 +1006,7 @@ fn user_configuration() -> anyhow::Result<()> {
10061006
3 |
10071007
4 | for a in range(0, int(y)):
10081008
|
1009-
info: `division-by-zero` was selected in the configuration file
1009+
info: rule `division-by-zero` was selected in the configuration file
10101010
10111011
error[unresolved-reference]: Name `prin` used when not defined
10121012
--> main.py:7:1
@@ -1016,7 +1016,7 @@ fn user_configuration() -> anyhow::Result<()> {
10161016
7 | prin(x)
10171017
| ^^^^
10181018
|
1019-
info: `unresolved-reference` is enabled by default
1019+
info: rule `unresolved-reference` is enabled by default
10201020
10211021
Found 2 diagnostics
10221022
@@ -1051,7 +1051,7 @@ fn user_configuration() -> anyhow::Result<()> {
10511051
3 |
10521052
4 | for a in range(0, int(y)):
10531053
|
1054-
info: `division-by-zero` was selected in the configuration file
1054+
info: rule `division-by-zero` was selected in the configuration file
10551055
10561056
warning[unresolved-reference]: Name `prin` used when not defined
10571057
--> main.py:7:1
@@ -1061,7 +1061,7 @@ fn user_configuration() -> anyhow::Result<()> {
10611061
7 | prin(x)
10621062
| ^^^^
10631063
|
1064-
info: `unresolved-reference` was selected in the configuration file
1064+
info: rule `unresolved-reference` was selected in the configuration file
10651065
10661066
Found 2 diagnostics
10671067
@@ -1110,7 +1110,7 @@ fn check_specific_paths() -> anyhow::Result<()> {
11101110
2 | y = 4 / 0 # error: division-by-zero
11111111
| ^^^^^
11121112
|
1113-
info: `division-by-zero` is enabled by default
1113+
info: rule `division-by-zero` is enabled by default
11141114
11151115
error[unresolved-import]: Cannot resolve imported module `main2`
11161116
--> project/other.py:2:6
@@ -1120,15 +1120,15 @@ fn check_specific_paths() -> anyhow::Result<()> {
11201120
3 |
11211121
4 | print(z)
11221122
|
1123-
info: `unresolved-import` is enabled by default
1123+
info: rule `unresolved-import` is enabled by default
11241124
11251125
error[unresolved-import]: Cannot resolve imported module `does_not_exist`
11261126
--> project/tests/test_main.py:2:8
11271127
|
11281128
2 | import does_not_exist # error: unresolved-import
11291129
| ^^^^^^^^^^^^^^
11301130
|
1131-
info: `unresolved-import` is enabled by default
1131+
info: rule `unresolved-import` is enabled by default
11321132
11331133
Found 3 diagnostics
11341134
@@ -1153,15 +1153,15 @@ fn check_specific_paths() -> anyhow::Result<()> {
11531153
3 |
11541154
4 | print(z)
11551155
|
1156-
info: `unresolved-import` is enabled by default
1156+
info: rule `unresolved-import` is enabled by default
11571157
11581158
error[unresolved-import]: Cannot resolve imported module `does_not_exist`
11591159
--> project/tests/test_main.py:2:8
11601160
|
11611161
2 | import does_not_exist # error: unresolved-import
11621162
| ^^^^^^^^^^^^^^
11631163
|
1164-
info: `unresolved-import` is enabled by default
1164+
info: rule `unresolved-import` is enabled by default
11651165
11661166
Found 2 diagnostics
11671167
@@ -1337,7 +1337,7 @@ fn defaults_to_a_new_python_version() -> anyhow::Result<()> {
13371337
4 | os.grantpt(1) # only available on unix, Python 3.13 or newer
13381338
| ^^^^^^^^^^
13391339
|
1340-
info: `unresolved-attribute` is enabled by default
1340+
info: rule `unresolved-attribute` is enabled by default
13411341
13421342
Found 1 diagnostic
13431343
@@ -1392,7 +1392,7 @@ fn cli_config_args_toml_string_basic() -> anyhow::Result<()> {
13921392
1 | print(x) # [unresolved-reference]
13931393
| ^
13941394
|
1395-
info: `unresolved-reference` was selected on the command line
1395+
info: rule `unresolved-reference` was selected on the command line
13961396
13971397
Found 1 diagnostic
13981398
@@ -1411,7 +1411,7 @@ fn cli_config_args_toml_string_basic() -> anyhow::Result<()> {
14111411
1 | print(x) # [unresolved-reference]
14121412
| ^
14131413
|
1414-
info: `unresolved-reference` is enabled by default
1414+
info: rule `unresolved-reference` is enabled by default
14151415
14161416
Found 1 diagnostic
14171417
@@ -1444,7 +1444,7 @@ fn cli_config_args_overrides_knot_toml() -> anyhow::Result<()> {
14441444
1 | print(x) # [unresolved-reference]
14451445
| ^
14461446
|
1447-
info: `unresolved-reference` was selected on the command line
1447+
info: rule `unresolved-reference` was selected on the command line
14481448
14491449
Found 1 diagnostic
14501450
@@ -1468,7 +1468,7 @@ fn cli_config_args_later_overrides_earlier() -> anyhow::Result<()> {
14681468
1 | print(x) # [unresolved-reference]
14691469
| ^
14701470
|
1471-
info: `unresolved-reference` was selected on the command line
1471+
info: rule `unresolved-reference` was selected on the command line
14721472
14731473
Found 1 diagnostic
14741474

crates/ty_python_semantic/resources/mdtest/snapshots/attribute_assignment.md_-_Attribute_assignment_-_Data_descriptors_-_Invalid_`__set__`_method_signature.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ error[invalid-assignment]: Invalid assignment to data descriptor attribute `attr
3535
11 | instance.attr = 1 # error: [invalid-assignment]
3636
| ^^^^^^^^^^^^^
3737
|
38-
info: `invalid-assignment` is enabled by default
38+
info: rule `invalid-assignment` is enabled by default
3939
4040
```

crates/ty_python_semantic/resources/mdtest/snapshots/attribute_assignment.md_-_Attribute_assignment_-_Data_descriptors_-_Invalid_argument_type.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ error[invalid-assignment]: Invalid assignment to data descriptor attribute `attr
3636
12 | instance.attr = "wrong" # error: [invalid-assignment]
3737
| ^^^^^^^^^^^^^
3838
|
39-
info: `invalid-assignment` is enabled by default
39+
info: rule `invalid-assignment` is enabled by default
4040
4141
```

crates/ty_python_semantic/resources/mdtest/snapshots/attribute_assignment.md_-_Attribute_assignment_-_Instance_attributes_with_class-level_defaults.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ error[invalid-assignment]: Object of type `Literal["wrong"]` is not assignable t
3636
7 |
3737
8 | C.attr = 1 # fine
3838
|
39-
info: `invalid-assignment` is enabled by default
39+
info: rule `invalid-assignment` is enabled by default
4040

4141
```
4242

@@ -48,6 +48,6 @@ error[invalid-assignment]: Object of type `Literal["wrong"]` is not assignable t
4848
9 | C.attr = "wrong" # error: [invalid-assignment]
4949
| ^^^^^^
5050
|
51-
info: `invalid-assignment` is enabled by default
51+
info: rule `invalid-assignment` is enabled by default
5252

5353
```

crates/ty_python_semantic/resources/mdtest/snapshots/attribute_assignment.md_-_Attribute_assignment_-_Possibly-unbound_attributes.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ warning[possibly-unbound-attribute]: Attribute `attr` on type `<class 'C'>` is p
3636
7 |
3737
8 | instance = C()
3838
|
39-
info: `possibly-unbound-attribute` is enabled by default
39+
info: rule `possibly-unbound-attribute` is enabled by default
4040

4141
```
4242

@@ -48,6 +48,6 @@ warning[possibly-unbound-attribute]: Attribute `attr` on type `C` is possibly un
4848
9 | instance.attr = 1 # error: [possibly-unbound-attribute]
4949
| ^^^^^^^^^^^^^
5050
|
51-
info: `possibly-unbound-attribute` is enabled by default
51+
info: rule `possibly-unbound-attribute` is enabled by default
5252

5353
```

crates/ty_python_semantic/resources/mdtest/snapshots/attribute_assignment.md_-_Attribute_assignment_-_Pure_instance_attributes.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ error[invalid-assignment]: Object of type `Literal["wrong"]` is not assignable t
3636
8 |
3737
9 | C.attr = 1 # error: [invalid-attribute-access]
3838
|
39-
info: `invalid-assignment` is enabled by default
39+
info: rule `invalid-assignment` is enabled by default
4040
4141
```
4242

@@ -49,6 +49,6 @@ error[invalid-attribute-access]: Cannot assign to instance attribute `attr` from
4949
9 | C.attr = 1 # error: [invalid-attribute-access]
5050
| ^^^^^^
5151
|
52-
info: `invalid-attribute-access` is enabled by default
52+
info: rule `invalid-attribute-access` is enabled by default
5353

5454
```

crates/ty_python_semantic/resources/mdtest/snapshots/attribute_assignment.md_-_Attribute_assignment_-_Setting_attributes_on_union_types.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ error[invalid-assignment]: Object of type `Literal[1]` is not assignable to attr
4646
12 |
4747
13 | class C2:
4848
|
49-
info: `invalid-assignment` is enabled by default
49+
info: rule `invalid-assignment` is enabled by default
5050

5151
```

0 commit comments

Comments
 (0)