@@ -166,6 +166,8 @@ FURB188.py:154:12: FURB188 [*] Prefer `removesuffix` over conditionally replacin
166166153 |
167167154 | return filename [:- builtins_len (extension )] if filename .endswith (extension ) else filename
168168 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB188
169+ 155 |
170+ 156 | def okay_steps ():
169171 |
170172 = help : Use removesuffix instead of ternary expression conditional upon endswith .
171173
@@ -175,3 +177,77 @@ FURB188.py:154:12: FURB188 [*] Prefer `removesuffix` over conditionally replacin
175177153 153 |
176178154 | - return filename [:- builtins_len (extension )] if filename .endswith (extension ) else filename
177179 154 | + return filename .removesuffix (extension )
180+ 155 155 |
181+ 156 156 | def okay_steps ():
182+ 157 157 | text = " !x!y!z"
183+
184+ FURB188 .py :158 :5 : FURB188 [* ] Prefer ` removeprefix` over conditionally replacing with slice .
185+ |
186+ 156 | def okay_steps ():
187+ 157 | text = " !x!y!z"
188+ 158 | if text .startswith (" !" ):
189+ | _____ ^
190+ 159 | | text = text [1 ::1 ]
191+ | | _________________________ ^ FURB188
192+ 160 | if text .startswith (" !" ):
193+ 161 | text = text [1 ::True ]
194+ |
195+ = help : Use removeprefix instead of assignment conditional upon startswith .
196+
197+ ℹ Safe fix
198+ 155 155 |
199+ 156 156 | def okay_steps ():
200+ 157 157 | text = " !x!y!z"
201+ 158 | - if text .startswith (" !" ):
202+ 159 | - text = text [1 ::1 ]
203+ 158 | + text = text .removeprefix (" !" )
204+ 160 159 | if text .startswith (" !" ):
205+ 161 160 | text = text [1 ::True ]
206+ 162 161 | if text .startswith (" !" ):
207+
208+ FURB188 .py :160 :5 : FURB188 [* ] Prefer ` removeprefix` over conditionally replacing with slice .
209+ |
210+ 158 | if text .startswith (" !" ):
211+ 159 | text = text [1 ::1 ]
212+ 160 | if text .startswith (" !" ):
213+ | _____ ^
214+ 161 | | text = text [1 ::True ]
215+ | | ____________________________ ^ FURB188
216+ 162 | if text .startswith (" !" ):
217+ 163 | text = text [1 ::None ]
218+ |
219+ = help : Use removeprefix instead of assignment conditional upon startswith .
220+
221+ ℹ Safe fix
222+ 157 157 | text = " !x!y!z"
223+ 158 158 | if text .startswith (" !" ):
224+ 159 159 | text = text [1 ::1 ]
225+ 160 | - if text .startswith (" !" ):
226+ 161 | - text = text [1 ::True ]
227+ 160 | + text = text .removeprefix (" !" )
228+ 162 161 | if text .startswith (" !" ):
229+ 163 162 | text = text [1 ::None ]
230+ 164 163 | print (text )
231+
232+ FURB188 .py :162 :5 : FURB188 [* ] Prefer ` removeprefix` over conditionally replacing with slice .
233+ |
234+ 160 | if text .startswith (" !" ):
235+ 161 | text = text [1 ::True ]
236+ 162 | if text .startswith (" !" ):
237+ | _____ ^
238+ 163 | | text = text [1 ::None ]
239+ | | ____________________________ ^ FURB188
240+ 164 | print (text )
241+ |
242+ = help : Use removeprefix instead of assignment conditional upon startswith .
243+
244+ ℹ Safe fix
245+ 159 159 | text = text [1 ::1 ]
246+ 160 160 | if text .startswith (" !" ):
247+ 161 161 | text = text [1 ::True ]
248+ 162 | - if text .startswith (" !" ):
249+ 163 | - text = text [1 ::None ]
250+ 162 | + text = text .removeprefix (" !" )
251+ 164 163 | print (text )
252+ 165 164 |
253+ 166 165 |
0 commit comments