mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 15:15:33 +00:00
Add convenience methods for iterating over all parameter nodes in a function (#11174)
This commit is contained in:
parent
8a887daeb4
commit
87929ad5f1
27 changed files with 399 additions and 448 deletions
|
@ -1755,23 +1755,19 @@ fn missing_args(checker: &mut Checker, docstring: &Docstring, docstrings_args: &
|
|||
|
||||
// Look for arguments that weren't included in the docstring.
|
||||
let mut missing_arg_names: FxHashSet<String> = FxHashSet::default();
|
||||
|
||||
// If this is a non-static method, skip `cls` or `self`.
|
||||
for ParameterWithDefault {
|
||||
parameter,
|
||||
default: _,
|
||||
range: _,
|
||||
} in function
|
||||
.parameters
|
||||
.posonlyargs
|
||||
.iter()
|
||||
.chain(&function.parameters.args)
|
||||
.chain(&function.parameters.kwonlyargs)
|
||||
.skip(
|
||||
// If this is a non-static method, skip `cls` or `self`.
|
||||
usize::from(
|
||||
docstring.definition.is_method()
|
||||
&& !is_staticmethod(&function.decorator_list, checker.semantic()),
|
||||
),
|
||||
)
|
||||
.iter_non_variadic_params()
|
||||
.skip(usize::from(
|
||||
docstring.definition.is_method()
|
||||
&& !is_staticmethod(&function.decorator_list, checker.semantic()),
|
||||
))
|
||||
{
|
||||
let arg_name = parameter.name.as_str();
|
||||
if !arg_name.starts_with('_') && !docstrings_args.contains(arg_name) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue