11-- -
22source : crates / ruff_linter / src / rules / refurb / mod .rs
3- snapshot_kind : text
43-- -
5- FURB188 .py :7 :5 : FURB188 [* ] Prefer ` removesuffix` over conditionally replacing with slice .
4+ FURB188 .py :7 :5 : FURB188 [* ] Prefer ` str. removesuffix() ` over conditionally replacing with slice .
65 |
76 6 | def remove_extension_via_slice (filename : str ) - > str :
87 7 | if filename .endswith (" .txt" ):
@@ -25,7 +24,7 @@ FURB188.py:7:5: FURB188 [*] Prefer `removesuffix` over conditionally replacing w
252410 9 | return filename
262511 10 |
2726
28- FURB188 .py :14 :5 : FURB188 [* ] Prefer ` removesuffix` over conditionally replacing with slice .
27+ FURB188 .py :14 :5 : FURB188 [* ] Prefer ` str. removesuffix() ` over conditionally replacing with slice .
2928 |
302913 | def remove_extension_via_slice_len (filename : str , extension : str ) - > str :
313014 | if filename .endswith (extension ):
@@ -48,7 +47,7 @@ FURB188.py:14:5: FURB188 [*] Prefer `removesuffix` over conditionally replacing
484717 16 | return filename
494818 17 |
5049
51- FURB188 .py :21 :12 : FURB188 [* ] Prefer ` removesuffix` over conditionally replacing with slice .
50+ FURB188 .py :21 :12 : FURB188 [* ] Prefer ` str. removesuffix() ` over conditionally replacing with slice .
5251 |
535220 | def remove_extension_via_ternary (filename : str ) - > str :
545321 | return filename [:- 4 ] if filename .endswith (" .txt" ) else filename
@@ -66,7 +65,7 @@ FURB188.py:21:12: FURB188 [*] Prefer `removesuffix` over conditionally replacing
666523 23 |
676624 24 | def remove_extension_via_ternary_with_len (filename : str , extension : str ) - > str :
6867
69- FURB188 .py :25 :12 : FURB188 [* ] Prefer ` removesuffix` over conditionally replacing with slice .
68+ FURB188 .py :25 :12 : FURB188 [* ] Prefer ` str. removesuffix() ` over conditionally replacing with slice .
7069 |
717024 | def remove_extension_via_ternary_with_len (filename : str , extension : str ) - > str :
727125 | return filename [:- len (extension )] if filename .endswith (extension ) else filename
@@ -84,7 +83,7 @@ FURB188.py:25:12: FURB188 [*] Prefer `removesuffix` over conditionally replacing
848327 27 |
858428 28 | def remove_prefix (filename : str ) - > str :
8685
87- FURB188 .py :29 :12 : FURB188 [* ] Prefer ` removeprefix` over conditionally replacing with slice .
86+ FURB188 .py :29 :12 : FURB188 [* ] Prefer ` str. removeprefix() ` over conditionally replacing with slice .
8887 |
898828 | def remove_prefix (filename : str ) - > str :
908929 | return filename [4 :] if filename .startswith (" abc-" ) else filename
@@ -102,7 +101,7 @@ FURB188.py:29:12: FURB188 [*] Prefer `removeprefix` over conditionally replacing
10210131 31 |
10310232 32 | def remove_prefix_via_len (filename : str , prefix : str ) - > str :
104103
105- FURB188 .py :33 :12 : FURB188 [* ] Prefer ` removeprefix` over conditionally replacing with slice .
104+ FURB188 .py :33 :12 : FURB188 [* ] Prefer ` str. removeprefix() ` over conditionally replacing with slice .
106105 |
10710632 | def remove_prefix_via_len (filename : str , prefix : str ) - > str :
10810733 | return filename [len (prefix ):] if filename .startswith (prefix ) else filename
@@ -120,7 +119,7 @@ FURB188.py:33:12: FURB188 [*] Prefer `removeprefix` over conditionally replacing
12011935 35 |
12112036 36 | # these should not
122121
123- FURB188 .py :146 :9 : FURB188 [* ] Prefer ` removesuffix` over conditionally replacing with slice .
122+ FURB188 .py :146 :9 : FURB188 [* ] Prefer ` str. removesuffix() ` over conditionally replacing with slice .
124123 |
125124144 | SUFFIX = " suffix"
126125145 |
@@ -141,7 +140,7 @@ FURB188.py:146:9: FURB188 [*] Prefer `removesuffix` over conditionally replacing
141140148 148 | def remove_prefix_comparable_literal_expr () - > None :
142141149 149 | return (" abc" " def" )[3 :] if (" abc" " def" ).startswith (" abc" ) else " abc" " def"
143142
144- FURB188 .py :149 :12 : FURB188 [* ] Prefer ` removeprefix` over conditionally replacing with slice .
143+ FURB188 .py :149 :12 : FURB188 [* ] Prefer ` str. removeprefix() ` over conditionally replacing with slice .
145144 |
146145148 | def remove_prefix_comparable_literal_expr () - > None :
147146149 | return (" abc" " def" )[3 :] if (" abc" " def" ).startswith (" abc" ) else " abc" " def"
@@ -161,7 +160,7 @@ FURB188.py:149:12: FURB188 [*] Prefer `removeprefix` over conditionally replacin
161160151 151 | def shadow_builtins (filename : str , extension : str ) - > None :
162161152 152 | from builtins import len as builtins_len
163162
164- FURB188 .py :154 :12 : FURB188 [* ] Prefer ` removesuffix` over conditionally replacing with slice .
163+ FURB188 .py :154 :12 : FURB188 [* ] Prefer ` str. removesuffix() ` over conditionally replacing with slice .
165164 |
166165152 | from builtins import len as builtins_len
167166153 |
@@ -182,7 +181,7 @@ FURB188.py:154:12: FURB188 [*] Prefer `removesuffix` over conditionally replacin
182181156 156 | def okay_steps ():
183182157 157 | text = " !x!y!z"
184183
185- FURB188 .py :158 :5 : FURB188 [* ] Prefer ` removeprefix` over conditionally replacing with slice .
184+ FURB188 .py :158 :5 : FURB188 [* ] Prefer ` str. removeprefix() ` over conditionally replacing with slice .
186185 |
187186156 | def okay_steps ():
188187157 | text = " !x!y!z"
@@ -206,7 +205,7 @@ FURB188.py:158:5: FURB188 [*] Prefer `removeprefix` over conditionally replacing
206205161 160 | text = text [1 ::True ]
207206162 161 | if text .startswith (" !" ):
208207
209- FURB188 .py :160 :5 : FURB188 [* ] Prefer ` removeprefix` over conditionally replacing with slice .
208+ FURB188 .py :160 :5 : FURB188 [* ] Prefer ` str. removeprefix() ` over conditionally replacing with slice .
210209 |
211210158 | if text .startswith (" !" ):
212211159 | text = text [1 ::1 ]
@@ -230,7 +229,7 @@ FURB188.py:160:5: FURB188 [*] Prefer `removeprefix` over conditionally replacing
230229163 162 | text = text [1 ::None ]
231230164 163 | print (text )
232231
233- FURB188 .py :162 :5 : FURB188 [* ] Prefer ` removeprefix` over conditionally replacing with slice .
232+ FURB188 .py :162 :5 : FURB188 [* ] Prefer ` str. removeprefix() ` over conditionally replacing with slice .
234233 |
235234160 | if text .startswith (" !" ):
236235161 | text = text [1 ::True ]
@@ -253,7 +252,7 @@ FURB188.py:162:5: FURB188 [*] Prefer `removeprefix` over conditionally replacing
253252165 164 |
254253166 165 |
255254
256- FURB188 .py :183 :5 : FURB188 [* ] Prefer ` removeprefix` over conditionally replacing with slice .
255+ FURB188 .py :183 :5 : FURB188 [* ] Prefer ` str. removeprefix() ` over conditionally replacing with slice .
257256 |
258257181 | # with fix ` text = text.removeprefix("ř")`
259258182 | text = " řetězec"
@@ -275,7 +274,7 @@ FURB188.py:183:5: FURB188 [*] Prefer `removeprefix` over conditionally replacing
275274186 185 |
276275187 186 | def handle_surrogates ():
277276
278- FURB188 .py :190 :5 : FURB188 [* ] Prefer ` removeprefix` over conditionally replacing with slice .
277+ FURB188 .py :190 :5 : FURB188 [* ] Prefer ` str. removeprefix() ` over conditionally replacing with slice .
279278 |
280279188 | # should be linted
281280189 | text = " \u d800\u dc00heythere"
@@ -299,7 +298,7 @@ FURB188.py:190:5: FURB188 [*] Prefer `removeprefix` over conditionally replacing
299298193 192 | if text .startswith (" \U 00010000" ):
300299194 193 | text = text [1 :]
301300
302- FURB188 .py :193 :5 : FURB188 [* ] Prefer ` removeprefix` over conditionally replacing with slice .
301+ FURB188 .py :193 :5 : FURB188 [* ] Prefer ` str. removeprefix() ` over conditionally replacing with slice .
303302 |
304303191 | text = text [2 :]
305304192 | text = " \U 00010000heythere"
0 commit comments