@@ -824,7 +824,9 @@ fn nursery_prefix() {
824
824
-:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix.
825
825
-:1:1: RUF902 Hey this is a stable test rule with an unsafe fix.
826
826
-:1:1: RUF903 Hey this is a stable test rule with a display only fix.
827
- Found 4 errors.
827
+ -:1:1: RUF920 Hey this is a deprecated test rule.
828
+ -:1:1: RUF921 Hey this is another deprecated test rule.
829
+ Found 6 errors.
828
830
[*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option).
829
831
830
832
----- stderr -----
@@ -846,7 +848,9 @@ fn nursery_all() {
846
848
-:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix.
847
849
-:1:1: RUF902 Hey this is a stable test rule with an unsafe fix.
848
850
-:1:1: RUF903 Hey this is a stable test rule with a display only fix.
849
- Found 5 errors.
851
+ -:1:1: RUF920 Hey this is a deprecated test rule.
852
+ -:1:1: RUF921 Hey this is another deprecated test rule.
853
+ Found 7 errors.
850
854
[*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option).
851
855
852
856
----- stderr -----
@@ -1094,28 +1098,45 @@ fn preview_enabled_group_ignore() {
1094
1098
#[ test]
1095
1099
fn removed_direct ( ) {
1096
1100
// Selection of a removed rule should fail
1097
- let mut cmd = RuffCheck :: default ( ) . args ( [ "--select" , "PLR1706 " ] ) . build ( ) ;
1101
+ let mut cmd = RuffCheck :: default ( ) . args ( [ "--select" , "RUF931 " ] ) . build ( ) ;
1098
1102
assert_cmd_snapshot ! ( cmd, @r###"
1099
1103
success: false
1100
1104
exit_code: 2
1101
1105
----- stdout -----
1102
1106
1103
1107
----- stderr -----
1104
1108
ruff failed
1105
- Cause: Rule `PLR1706` was removed and cannot be selected.
1109
+ Cause: Rule `RUF931` was removed and cannot be selected.
1110
+ "### ) ;
1111
+ }
1112
+
1113
+ #[ test]
1114
+ fn removed_direct_multiple ( ) {
1115
+ // Selection of multiple removed rule should fail with a message
1116
+ // including all the rules
1117
+ let mut cmd = RuffCheck :: default ( )
1118
+ . args ( [ "--select" , "RUF930" , "--select" , "RUF931" ] )
1119
+ . build ( ) ;
1120
+ assert_cmd_snapshot ! ( cmd, @r###"
1121
+ success: false
1122
+ exit_code: 2
1123
+ ----- stdout -----
1124
+
1125
+ ----- stderr -----
1126
+ ruff failed
1127
+ Cause: The following rules have been removed and cannot be selected:
1128
+ - RUF930
1129
+ - RUF931
1130
+
1106
1131
"### ) ;
1107
1132
}
1108
1133
1109
1134
#[ test]
1110
1135
fn removed_indirect ( ) {
1111
1136
// Selection _including_ a removed rule without matching should not fail
1112
1137
// nor should the rule be used
1113
- let mut cmd = RuffCheck :: default ( ) . args ( [ "--select" , "PLR" ] ) . build ( ) ;
1114
- assert_cmd_snapshot ! ( cmd. pass_stdin( r###"
1115
- # This would have been a PLR1706 violation
1116
- x, y = 1, 2
1117
- maximum = x >= y and x or y
1118
- """### ) , @r###"
1138
+ let mut cmd = RuffCheck :: default ( ) . args ( [ "--select" , "RUF93" ] ) . build ( ) ;
1139
+ assert_cmd_snapshot ! ( cmd, @r###"
1119
1140
success: true
1120
1141
exit_code: 0
1121
1142
----- stdout -----
@@ -1128,74 +1149,49 @@ maximum = x >= y and x or y
1128
1149
fn deprecated_direct ( ) {
1129
1150
// Selection of a deprecated rule without preview enabled should still work
1130
1151
// but a warning should be displayed
1131
- let mut cmd = RuffCheck :: default ( ) . args ( [ "--select" , "TRY200" ] ) . build ( ) ;
1132
- assert_cmd_snapshot ! ( cmd
1133
- . pass_stdin( r###"
1134
- def reciprocal(n):
1135
- try:
1136
- return 1 / n
1137
- except ZeroDivisionError:
1138
- raise ValueError()
1139
- "### ) , @r###"
1152
+ let mut cmd = RuffCheck :: default ( ) . args ( [ "--select" , "RUF920" ] ) . build ( ) ;
1153
+ assert_cmd_snapshot ! ( cmd, @r###"
1140
1154
success: false
1141
1155
exit_code: 1
1142
1156
----- stdout -----
1143
- -:6:9: TRY200 Use `raise from` to specify exception cause
1157
+ -:1:1: RUF920 Hey this is a deprecated test rule.
1144
1158
Found 1 error.
1145
1159
1146
1160
----- stderr -----
1147
- warning: Rule `TRY200 ` is deprecated and will be removed in a future release.
1161
+ warning: Rule `RUF920 ` is deprecated and will be removed in a future release.
1148
1162
"### ) ;
1149
1163
}
1150
1164
1151
1165
#[ test]
1152
1166
fn deprecated_multiple_direct ( ) {
1153
1167
let mut cmd = RuffCheck :: default ( )
1154
- . args ( [ "--select" , "ANN101 " , "--select" , "ANN102 " ] )
1168
+ . args ( [ "--select" , "RUF920 " , "--select" , "RUF921 " ] )
1155
1169
. build ( ) ;
1156
- assert_cmd_snapshot ! ( cmd
1157
- . pass_stdin( r###"
1158
- class Foo:
1159
- def a(self):
1160
- pass
1161
-
1162
- @classmethod
1163
- def b(cls):
1164
- pass
1165
- "### ) , @r###"
1170
+ assert_cmd_snapshot ! ( cmd, @r###"
1166
1171
success: false
1167
1172
exit_code: 1
1168
1173
----- stdout -----
1169
- -:3:11: ANN101 Missing type annotation for `self` in method
1170
- -:7:11: ANN102 Missing type annotation for `cls` in classmethod
1174
+ -:1:1: RUF920 Hey this is a deprecated test rule.
1175
+ -:1:1: RUF921 Hey this is another deprecated test rule.
1171
1176
Found 2 errors.
1172
1177
1173
1178
----- stderr -----
1174
- warning: Rule `ANN102 ` is deprecated and will be removed in a future release.
1175
- warning: Rule `ANN101 ` is deprecated and will be removed in a future release.
1179
+ warning: Rule `RUF921 ` is deprecated and will be removed in a future release.
1180
+ warning: Rule `RUF920 ` is deprecated and will be removed in a future release.
1176
1181
"### ) ;
1177
1182
}
1178
1183
1179
1184
#[ test]
1180
1185
fn deprecated_indirect ( ) {
1181
- // `ANN ` includes deprecated rules `ANN101` and `ANN102` but should not warn
1186
+ // `RUF92 ` includes deprecated rules but should not warn
1182
1187
// since it is not a "direct" selection
1183
- let mut cmd = RuffCheck :: default ( ) . args ( [ "--select" , "ANN1" ] ) . build ( ) ;
1184
- assert_cmd_snapshot ! ( cmd
1185
- . pass_stdin( r###"
1186
- class Foo:
1187
- def a(self):
1188
- pass
1189
-
1190
- @classmethod
1191
- def b(cls):
1192
- pass
1193
- "### ) , @r###"
1188
+ let mut cmd = RuffCheck :: default ( ) . args ( [ "--select" , "RUF92" ] ) . build ( ) ;
1189
+ assert_cmd_snapshot ! ( cmd, @r###"
1194
1190
success: false
1195
1191
exit_code: 1
1196
1192
----- stdout -----
1197
- -:3:11: ANN101 Missing type annotation for `self` in method
1198
- -:7:11: ANN102 Missing type annotation for `cls` in classmethod
1193
+ -:1:1: RUF920 Hey this is a deprecated test rule.
1194
+ -:1:1: RUF921 Hey this is another deprecated test rule.
1199
1195
Found 2 errors.
1200
1196
1201
1197
----- stderr -----
@@ -1206,40 +1202,26 @@ class Foo:
1206
1202
fn deprecated_direct_preview_enabled ( ) {
1207
1203
// Direct selection of a deprecated rule in preview should fail
1208
1204
let mut cmd = RuffCheck :: default ( )
1209
- . args ( [ "--select" , "TRY200 " , "--preview" ] )
1205
+ . args ( [ "--select" , "RUF920 " , "--preview" ] )
1210
1206
. build ( ) ;
1211
- assert_cmd_snapshot ! ( cmd
1212
- . pass_stdin( r###"
1213
- def reciprocal(n):
1214
- try:
1215
- return 1 / n
1216
- except ZeroDivisionError:
1217
- raise ValueError()
1218
- "### ) , @r###"
1207
+ assert_cmd_snapshot ! ( cmd, @r###"
1219
1208
success: false
1220
1209
exit_code: 2
1221
1210
----- stdout -----
1222
1211
1223
1212
----- stderr -----
1224
1213
ruff failed
1225
- Cause: Selection of deprecated rule `TRY200 ` is not allowed when preview is enabled.
1214
+ Cause: Selection of deprecated rule `RUF920 ` is not allowed when preview is enabled.
1226
1215
"### ) ;
1227
1216
}
1228
1217
1229
1218
#[ test]
1230
1219
fn deprecated_indirect_preview_enabled ( ) {
1231
- // `TRY200 ` is deprecated and should be off by default in preview.
1220
+ // `RUF920 ` is deprecated and should be off by default in preview.
1232
1221
let mut cmd = RuffCheck :: default ( )
1233
- . args ( [ "--select" , "TRY " , "--preview" ] )
1222
+ . args ( [ "--select" , "RUF92 " , "--preview" ] )
1234
1223
. build ( ) ;
1235
- assert_cmd_snapshot ! ( cmd
1236
- . pass_stdin( r###"
1237
- def reciprocal(n):
1238
- try:
1239
- return 1 / n
1240
- except ZeroDivisionError:
1241
- raise ValueError()
1242
- "### ) , @r###"
1224
+ assert_cmd_snapshot ! ( cmd, @r###"
1243
1225
success: true
1244
1226
exit_code: 0
1245
1227
----- stdout -----
@@ -1253,25 +1235,18 @@ fn deprecated_multiple_direct_preview_enabled() {
1253
1235
// Direct selection of the deprecated rules in preview should fail with
1254
1236
// a message listing all of the rule codes
1255
1237
let mut cmd = RuffCheck :: default ( )
1256
- . args ( [ "--select" , "ANN101 " , "--select" , "ANN102 " , "--preview" ] )
1238
+ . args ( [ "--select" , "RUF920 " , "--select" , "RUF921 " , "--preview" ] )
1257
1239
. build ( ) ;
1258
- assert_cmd_snapshot ! ( cmd
1259
- . pass_stdin( r###"
1260
- def reciprocal(n):
1261
- try:
1262
- return 1 / n
1263
- except ZeroDivisionError:
1264
- raise ValueError()
1265
- "### ) , @r###"
1240
+ assert_cmd_snapshot ! ( cmd, @r###"
1266
1241
success: false
1267
1242
exit_code: 2
1268
1243
----- stdout -----
1269
1244
1270
1245
----- stderr -----
1271
1246
ruff failed
1272
1247
Cause: Selection of deprecated rules is not allowed when preview is enabled. Remove selection of:
1273
- - ANN102
1274
- - ANN101
1248
+ - RUF921
1249
+ - RUF920
1275
1250
1276
1251
"### ) ;
1277
1252
}
@@ -1793,7 +1768,9 @@ extend-safe-fixes = ["RUF9"]
1793
1768
-:1:1: RUF901 Hey this is a stable test rule with a safe fix.
1794
1769
-:1:1: RUF902 [*] Hey this is a stable test rule with an unsafe fix.
1795
1770
-:1:1: RUF903 Hey this is a stable test rule with a display only fix.
1796
- Found 4 errors.
1771
+ -:1:1: RUF920 Hey this is a deprecated test rule.
1772
+ -:1:1: RUF921 Hey this is another deprecated test rule.
1773
+ Found 6 errors.
1797
1774
[*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option).
1798
1775
1799
1776
----- stderr -----
0 commit comments