ruff icon indicating copy to clipboard operation
ruff copied to clipboard

`repeated-isinstance-calls` is a duplicate rule of `duplicate-isinstance-call`

Open Skylion007 opened this issue 2 years ago • 4 comments

These two rules do the exact same thing but, have slightly different logic. They should be an alias of one another but appear to each be there own rule: https://docs.astral.sh/ruff/rules/repeated-isinstance-calls/ and https://docs.astral.sh/ruff/rules/duplicate-isinstance-call/ do the same thing, and have the same autofix implemented. Seems like this wasn't notice when the PR was merged https://github.com/astral-sh/ruff/pull/4792

Skylion007 avatar Oct 22 '23 18:10 Skylion007

I prefer the original logic that always converted the isinstance call to check against a type tuple. While the new Union logic is really snazzy in Python 3.11, it is a little bit slower in practice and having the pyupgrade rule take care of it means we can opt out of it which is not possible with the PyLint check

Skylion007 avatar Oct 22 '23 19:10 Skylion007

Thanks, will dedupe!

charliermarsh avatar Oct 23 '23 03:10 charliermarsh

@charliermarsh do we want to deprecate one of them? which one?

zanieb avatar Jan 30 '24 01:01 zanieb

@zanieb - I'd vote to keep the flake8-simplify version since we're more closely anchored to that ecosystem and it came first.

charliermarsh avatar Jan 30 '24 01:01 charliermarsh

Resolved in #12021

dhruvmanila avatar Jun 25 '24 13:06 dhruvmanila