You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SIM101 rule suggests replacing isinstance(a. b) or isinstance(a, c) with isinstance(a, (b, c)) - but the lint and autofix also trigger when there is an intermediate term in the or-expression. This is a problem because code can (and does) rely on short-circuiting evaluation in some such cases. For example, ruff --isolated --select=SIM101 --fix demo.py will break:
x=isinstance("", int) orTrueorisinstance("", undefined_name)
# x = isinstance("", (int, undefined_name)) or True # incorrect fix!
I found this while experimenting with ruff in shed, which has a similar fixer.
The text was updated successfully, but these errors were encountered:
The
SIM101
rule suggests replacingisinstance(a. b) or isinstance(a, c)
withisinstance(a, (b, c))
- but the lint and autofix also trigger when there is an intermediate term in theor
-expression. This is a problem because code can (and does) rely on short-circuiting evaluation in some such cases. For example,ruff --isolated --select=SIM101 --fix demo.py
will break:I found this while experimenting with
ruff
inshed
, which has a similar fixer.The text was updated successfully, but these errors were encountered: