ruff
ruff copied to clipboard
[BUG] `ruff` does not correctly lint positional only arguments
Consider the following snippet:
# contents of ruff_bug_report.py
def add(x: int, y: int, /) -> int:
return x + y
z = add(x=1, y=1)
This code fails because of positional only arguments.
❯ python ruff_bug_report.py
Traceback (most recent call last):
File "/home/anirban/sktime-fork/ruff_bug_report.py", line 5, in <module>
z = add(x=1, y=1)
TypeError: add() got some positional-only arguments passed as keyword arguments: 'x, y'
However, ruff check passes.
❯ ruff check ruff_bug_report.py
All checks passed!
This check is part of pylint, ref. E3102.
I am using ruff==0.6.4, and observed this on multiple python versions (3.10, 3.11) on different operating systems (macOS, Windows).
Thanks for opening this issue.
I quickly checked, and Ruff doesn't yet implement the rule mentioned. This is most likely because it would require multifile analysis, or the rule would only flag calls to functions defined in the same file, which isn't that useful.
Oh, I wasn't aware of lack of multi file analysis. Do you mean that if I incorrectly use a function/class/etc. defuned in module A in a different module B, as of now ruff is unable to flag those cases?
Oh, I wasn't aware of lack of multi file analysis. Do you mean that if I incorrectly use a function/class/etc. defuned in module A in a different module B, as of now ruff is unable to flag those cases?
That's correct. Ruff can't resolve functions across files. That's also the reason why many rules that require that kind of information aren't implemented today. We're working towards supporting this but it will take some more time until it becomes available in ruff.