[ty] disable division-by-zero by default#18220
Conversation
|
|
We should re-enable it for mypy primer here https://github.com/astral-sh/ruff/blob/main/.github/mypy-primer-ty.toml I'm also not sure if we should disable it. I found the feedback around narrowing limitations useful and we'll miss out on that when it's disabled. |
e2198de to
545c7ed
Compare
I feel strongly that we need to improve our focus on the most important issues and avoid (ourselves and our users) being distracted by low-priority issues. If we keep it enabled in the ecosystem, we don't lose this feedback when we choose to make it a priority. |
|
You also need to update the CLI tests. It's used a lot in there because it was one of the first rules that triggered (and it doesn't requier a lot of set up code) |
Thanks. I was able to update those tests without having to change the code examples -- the same properties of the configuration can be demonstrated by going from "ignored" to "warn" as were previously demonstrated by going from "error" to "warn". |
Small correction: we do narrow literals from (in)equality checks, but we don't yet narrow literals from |
|
Yes, that's what I meant. I guess there isn't a simple term for just "greater or less-than checks"! |
Summary
I think
division-by-zerois a low-value diagnostic in general; most real division-by-zero errors (especially those that are less obvious to the human eye) will occur on values typed asint, in which case we don't issue the diagnostic anyway. Mypy and pyright do not emit this diagnostic.Currently the diagnostic is prone to false positives because a) we do not silence it in unreachable code, and b) we do not implement narrowing of literals from inequality checks. We will probably fix (a) regardless, but (b) is low priority apart from division-by-zero.
I think we have many more important things to do and should not allow false positives on a low-value diagnostic to be a distraction. Not opposed to re-enabling this diagnostic in future when we can prioritize reducing its false positives.
References astral-sh/ty#443
Test Plan
Existing tests.