I'm not sure even if it is ruff's job to catch the undefined argument to a function, but is there a tool that does this? or is there a ruff configuration that I'm missing to add so that ruff can do this?
from typing import Optional
def my_func(bar: int, baz: int, foo: Optional[int] = None) -> int:
if foo:
return foo + bar + baz
else:
return bar + baz
my_func(foo=1, bar=2, baz=3)
my_func(bar=2, baz=3)
my_func(f=1, bar=2, baz=3) # this should have been caught by ruff, but isn't and I'm
my ruff.toml
select = [
"F", # https://beta.ruff.rs/docs/rules/#pyflakes-f
"W", # https://beta.ruff.rs/docs/rules/#warning-w
"E", # https://beta.ruff.rs/docs/rules/#error-e
"I", # https://beta.ruff.rs/docs/rules/#isort-i
"N", # https://beta.ruff.rs/docs/rules/#pep8-naming-n
"ANN", # https://beta.ruff.rs/docs/rules/#flake8-annotations-ann
"B", # https://beta.ruff.rs/docs/rules/#flake8-bugbear-b
"RUF", # https://beta.ruff.rs/docs/rules/#ruff-specific-rules-ruf
"PT", # https://beta.ruff.rs/docs/rules/#flake8-pytest-style-pt
"D",
]
include = ["*.py"]
force-exclude = true
fixable = ["ALL"]
pydocstyle.convention = "numpy"
exclude = [".mypy_cache", ".ruff_cache", ".venv", "__pypackages__"]
ignore = [
"ANN101", # https://beta.ruff.rs/docs/rules/#flake8-annotations-ann -- missing self type annotation
"E501", # Line-length is handled by black
"N812", # https://beta.ruff.rs/docs/rules/lowercase-imported-as-non-lowercase/
"ANN401", # Ignore typing Any
"D1", # Don't complain about missing docstrings
]
Ruff does not currently support this. Quoting the Ruff FAQ: