Open omgMath opened 6 months ago
Thanks for the report. I believe this is the current limitation of many rules where they don't try to resolve the type of a variable. It will only check if it's a literal expression like []
, {}
, etc.
I feel like we could catch this via the type annotation though?
Yeah, it should be doable
Just confirming that as of ruff 0.6.6 it still doesn't catch the constant via type annotations:
TEST = [1, 2, 3]
def test(l: list[int] = [1, 2, 3]):
pass
def test2(l: list[int] = TEST):
pass
Does https://github.com/astral-sh/ruff/pull/11122 need more work? Anything that we could help with?
Hi I found a case where my expectations does not meet the results reported by ruff. But first, let's start with the issue basics:
ruff 0.4.0
ruff check case.py --select ALL --ignore D,FA --isolated
Where my
case.py
contains the following lines:I would have hoped that this would be detected by rule B006 (or any other rule), but sadly it is not.
However, the rule detects the issue if instead of
DEFAULT_ENTRIES
we use[]
. Thanks for checking!