@@ -182,4 +182,206 @@ help: Merge `isinstance` calls for `a`
182182 - if (isinstance (a , int )) or (isinstance (a , float )):
18318353 + if isinstance (a , (int , float )):
18418454 | pass
185+ 55 |
186+ 56 | # Regression test for : https :// github.com/astral-sh/ruff/issues/19601
187+ note : This is an unsafe fix and may change runtime behavior
188+
189+ SIM101 [* ] Multiple ` isinstance` calls for expression , merge into a single call
190+ -- > SIM101 .py :60 :1
191+ |
192+ 58 | # the AST mangles f - strings whose format spec contains escape sequences or
193+ 59 | # whose interpolations include lambdas .
194+ 60 | isinstance (f " {(lambda: 0)}" , int ) or isinstance (f " {(lambda: 0)}" , str )
195+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
196+ 61 | isinstance (f " {0:{(lambda: 0)}}" , int ) or isinstance (f " {0:{(lambda: 0)}}" , str )
197+ 62 | isinstance (f " {0:\x22 }" , int ) or isinstance (f " {0:\x22 }" , str )
198+ |
199+ help : Merge ` isinstance` calls
200+ 57 | # The fix must preserve the target ' s source verbatim — re-rendering through
201+ 58 | # the AST mangles f - strings whose format spec contains escape sequences or
202+ 59 | # whose interpolations include lambdas .
203+ - isinstance (f " {(lambda: 0)}" , int ) or isinstance (f " {(lambda: 0)}" , str )
204+ 60 + isinstance (f " {(lambda: 0)}" , (int , str ))
205+ 61 | isinstance (f " {0:{(lambda: 0)}}" , int ) or isinstance (f " {0:{(lambda: 0)}}" , str )
206+ 62 | isinstance (f " {0:\x22 }" , int ) or isinstance (f " {0:\x22 }" , str )
207+ 63 | isinstance (f " {0:\x7b }" , int ) or isinstance (f " {0:\x7b }" , str )
208+ note : This is an unsafe fix and may change runtime behavior
209+
210+ SIM101 [* ] Multiple ` isinstance` calls for expression , merge into a single call
211+ -- > SIM101 .py :61 :1
212+ |
213+ 59 | # whose interpolations include lambdas .
214+ 60 | isinstance (f " {(lambda: 0)}" , int ) or isinstance (f " {(lambda: 0)}" , str )
215+ 61 | isinstance (f " {0:{(lambda: 0)}}" , int ) or isinstance (f " {0:{(lambda: 0)}}" , str )
216+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
217+ 62 | isinstance (f " {0:\x22 }" , int ) or isinstance (f " {0:\x22 }" , str )
218+ 63 | isinstance (f " {0:\x7b }" , int ) or isinstance (f " {0:\x7b }" , str )
219+ |
220+ help : Merge ` isinstance` calls
221+ 58 | # the AST mangles f - strings whose format spec contains escape sequences or
222+ 59 | # whose interpolations include lambdas .
223+ 60 | isinstance (f " {(lambda: 0)}" , int ) or isinstance (f " {(lambda: 0)}" , str )
224+ - isinstance (f " {0:{(lambda: 0)}}" , int ) or isinstance (f " {0:{(lambda: 0)}}" , str )
225+ 61 + isinstance (f " {0:{(lambda: 0)}}" , (int , str ))
226+ 62 | isinstance (f " {0:\x22 }" , int ) or isinstance (f " {0:\x22 }" , str )
227+ 63 | isinstance (f " {0:\x7b }" , int ) or isinstance (f " {0:\x7b }" , str )
228+ 64 |
229+ note : This is an unsafe fix and may change runtime behavior
230+
231+ SIM101 [* ] Multiple ` isinstance` calls for expression , merge into a single call
232+ -- > SIM101 .py :62 :1
233+ |
234+ 60 | isinstance (f " {(lambda: 0)}" , int ) or isinstance (f " {(lambda: 0)}" , str )
235+ 61 | isinstance (f " {0:{(lambda: 0)}}" , int ) or isinstance (f " {0:{(lambda: 0)}}" , str )
236+ 62 | isinstance (f " {0:\x22 }" , int ) or isinstance (f " {0:\x22 }" , str )
237+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
238+ 63 | isinstance (f " {0:\x7b }" , int ) or isinstance (f " {0:\x7b }" , str )
239+ |
240+ help : Merge ` isinstance` calls
241+ 59 | # whose interpolations include lambdas .
242+ 60 | isinstance (f " {(lambda: 0)}" , int ) or isinstance (f " {(lambda: 0)}" , str )
243+ 61 | isinstance (f " {0:{(lambda: 0)}}" , int ) or isinstance (f " {0:{(lambda: 0)}}" , str )
244+ - isinstance (f " {0:\x22 }" , int ) or isinstance (f " {0:\x22 }" , str )
245+ 62 + isinstance (f " {0:\x22 }" , (int , str ))
246+ 63 | isinstance (f " {0:\x7b }" , int ) or isinstance (f " {0:\x7b }" , str )
247+ 64 |
248+ 65 | # Regression test for : https :// github.com/astral-sh/ruff/pull/25061
249+ note : This is an unsafe fix and may change runtime behavior
250+
251+ SIM101 [* ] Multiple ` isinstance` calls for expression , merge into a single call
252+ -- > SIM101 .py :63 :1
253+ |
254+ 61 | isinstance (f " {0:{(lambda: 0)}}" , int ) or isinstance (f " {0:{(lambda: 0)}}" , str )
255+ 62 | isinstance (f " {0:\x22 }" , int ) or isinstance (f " {0:\x22 }" , str )
256+ 63 | isinstance (f " {0:\x7b }" , int ) or isinstance (f " {0:\x7b }" , str )
257+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
258+ 64 |
259+ 65 | # Regression test for : https :// github.com/astral-sh/ruff/pull/25061
260+ |
261+ help : Merge ` isinstance` calls
262+ 60 | isinstance (f " {(lambda: 0)}" , int ) or isinstance (f " {(lambda: 0)}" , str )
263+ 61 | isinstance (f " {0:{(lambda: 0)}}" , int ) or isinstance (f " {0:{(lambda: 0)}}" , str )
264+ 62 | isinstance (f " {0:\x22 }" , int ) or isinstance (f " {0:\x22 }" , str )
265+ - isinstance (f " {0:\x7b }" , int ) or isinstance (f " {0:\x7b }" , str )
266+ 63 + isinstance (f " {0:\x7b }" , (int , str ))
267+ 64 |
268+ 65 | # Regression test for : https :// github.com/astral-sh/ruff/pull/25061
269+ 66 | types = (int ,)
270+ note : This is an unsafe fix and may change runtime behavior
271+
272+ SIM101 [* ] Multiple ` isinstance` calls for ` x` , merge into a single call
273+ -- > SIM101 .py :67 :1
274+ |
275+ 65 | # Regression test for : https :// github.com/astral-sh/ruff/pull/25061
276+ 66 | types = (int ,)
277+ 67 | isinstance (x , (* types ,)) or isinstance (x , ())
278+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
279+ 68 | isinstance (x , (* types ,)) or isinstance (x , (* types ,))
280+ 69 | isinstance (x , ()) or isinstance (x , int )
281+ |
282+ help : Merge ` isinstance` calls for ` x`
283+ 64 |
284+ 65 | # Regression test for : https :// github.com/astral-sh/ruff/pull/25061
285+ 66 | types = (int ,)
286+ - isinstance (x , (* types ,)) or isinstance (x , ())
287+ 67 + isinstance (x , (* types ,))
288+ 68 | isinstance (x , (* types ,)) or isinstance (x , (* types ,))
289+ 69 | isinstance (x , ()) or isinstance (x , int )
290+ 70 | isinstance (x , ()) or isinstance (x , ())
291+ note : This is an unsafe fix and may change runtime behavior
292+
293+ SIM101 [* ] Multiple ` isinstance` calls for ` x` , merge into a single call
294+ -- > SIM101 .py :68 :1
295+ |
296+ 66 | types = (int ,)
297+ 67 | isinstance (x , (* types ,)) or isinstance (x , ())
298+ 68 | isinstance (x , (* types ,)) or isinstance (x , (* types ,))
299+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
300+ 69 | isinstance (x , ()) or isinstance (x , int )
301+ 70 | isinstance (x , ()) or isinstance (x , ())
302+ |
303+ help : Merge ` isinstance` calls for ` x`
304+ 65 | # Regression test for : https :// github.com/astral-sh/ruff/pull/25061
305+ 66 | types = (int ,)
306+ 67 | isinstance (x , (* types ,)) or isinstance (x , ())
307+ - isinstance (x , (* types ,)) or isinstance (x , (* types ,))
308+ 68 + isinstance (x , (* types , * types ))
309+ 69 | isinstance (x , ()) or isinstance (x , int )
310+ 70 | isinstance (x , ()) or isinstance (x , ())
311+ 71 | ((isinstance (x , int )) or isinstance (x , str ))
312+ note : This is an unsafe fix and may change runtime behavior
313+
314+ SIM101 [* ] Multiple ` isinstance` calls for ` x` , merge into a single call
315+ -- > SIM101 .py :69 :1
316+ |
317+ 67 | isinstance (x , (* types ,)) or isinstance (x , ())
318+ 68 | isinstance (x , (* types ,)) or isinstance (x , (* types ,))
319+ 69 | isinstance (x , ()) or isinstance (x , int )
320+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
321+ 70 | isinstance (x , ()) or isinstance (x , ())
322+ 71 | ((isinstance (x , int )) or isinstance (x , str ))
323+ |
324+ help : Merge ` isinstance` calls for ` x`
325+ 66 | types = (int ,)
326+ 67 | isinstance (x , (* types ,)) or isinstance (x , ())
327+ 68 | isinstance (x , (* types ,)) or isinstance (x , (* types ,))
328+ - isinstance (x , ()) or isinstance (x , int )
329+ 69 + isinstance (x , (int ))
330+ 70 | isinstance (x , ()) or isinstance (x , ())
331+ 71 | ((isinstance (x , int )) or isinstance (x , str ))
332+ 72 | isinstance (x , int ) or (isinstance (x , str ))
333+ note : This is an unsafe fix and may change runtime behavior
334+
335+ SIM101 [* ] Multiple ` isinstance` calls for ` x` , merge into a single call
336+ -- > SIM101 .py :70 :1
337+ |
338+ 68 | isinstance (x , (* types ,)) or isinstance (x , (* types ,))
339+ 69 | isinstance (x , ()) or isinstance (x , int )
340+ 70 | isinstance (x , ()) or isinstance (x , ())
341+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
342+ 71 | ((isinstance (x , int )) or isinstance (x , str ))
343+ 72 | isinstance (x , int ) or (isinstance (x , str ))
344+ |
345+ help : Merge ` isinstance` calls for ` x`
346+ 67 | isinstance (x , (* types ,)) or isinstance (x , ())
347+ 68 | isinstance (x , (* types ,)) or isinstance (x , (* types ,))
348+ 69 | isinstance (x , ()) or isinstance (x , int )
349+ - isinstance (x , ()) or isinstance (x , ())
350+ 70 + isinstance (x , ())
351+ 71 | ((isinstance (x , int )) or isinstance (x , str ))
352+ 72 | isinstance (x , int ) or (isinstance (x , str ))
353+ note : This is an unsafe fix and may change runtime behavior
354+
355+ SIM101 [* ] Multiple ` isinstance` calls for ` x` , merge into a single call
356+ -- > SIM101 .py :71 :2
357+ |
358+ 69 | isinstance (x , ()) or isinstance (x , int )
359+ 70 | isinstance (x , ()) or isinstance (x , ())
360+ 71 | ((isinstance (x , int )) or isinstance (x , str ))
361+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
362+ 72 | isinstance (x , int ) or (isinstance (x , str ))
363+ |
364+ help : Merge ` isinstance` calls for ` x`
365+ 68 | isinstance (x , (* types ,)) or isinstance (x , (* types ,))
366+ 69 | isinstance (x , ()) or isinstance (x , int )
367+ 70 | isinstance (x , ()) or isinstance (x , ())
368+ - ((isinstance (x , int )) or isinstance (x , str ))
369+ 71 + (isinstance (x , (int , str )))
370+ 72 | isinstance (x , int ) or (isinstance (x , str ))
371+ note : This is an unsafe fix and may change runtime behavior
372+
373+ SIM101 [* ] Multiple ` isinstance` calls for ` x` , merge into a single call
374+ -- > SIM101 .py :72 :1
375+ |
376+ 70 | isinstance (x , ()) or isinstance (x , ())
377+ 71 | ((isinstance (x , int )) or isinstance (x , str ))
378+ 72 | isinstance (x , int ) or (isinstance (x , str ))
379+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
380+ |
381+ help : Merge ` isinstance` calls for ` x`
382+ 69 | isinstance (x , ()) or isinstance (x , int )
383+ 70 | isinstance (x , ()) or isinstance (x , ())
384+ 71 | ((isinstance (x , int )) or isinstance (x , str ))
385+ - isinstance (x , int ) or (isinstance (x , str ))
386+ 72 + isinstance (x , (int , str ))
185387note : This is an unsafe fix and may change runtime behavior
0 commit comments