mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-22 12:35:08 +00:00
Move includes_arg_name
onto Parameters
(#6282)
## Summary Like #6279, no reason for this to be a standalone method.
This commit is contained in:
parent
fd40864924
commit
23b8fc4366
6 changed files with 40 additions and 40 deletions
|
@ -9,8 +9,8 @@ use ruff_text_size::TextRange;
|
|||
use crate::call_path::CallPath;
|
||||
use crate::statement_visitor::{walk_body, walk_stmt, StatementVisitor};
|
||||
use crate::{
|
||||
self as ast, Arguments, Constant, ExceptHandler, Expr, MatchCase, Parameters, Pattern, Ranged,
|
||||
Stmt, TypeParam,
|
||||
self as ast, Arguments, Constant, ExceptHandler, Expr, MatchCase, Pattern, Ranged, Stmt,
|
||||
TypeParam,
|
||||
};
|
||||
|
||||
/// Return `true` if the `Stmt` is a compound statement (as opposed to a simple statement).
|
||||
|
@ -712,30 +712,6 @@ pub fn extract_handled_exceptions(handlers: &[ExceptHandler]) -> Vec<&Expr> {
|
|||
handled_exceptions
|
||||
}
|
||||
|
||||
/// Returns `true` if the given name is included in the given [`Parameters`].
|
||||
pub fn includes_arg_name(name: &str, parameters: &Parameters) -> bool {
|
||||
if parameters
|
||||
.posonlyargs
|
||||
.iter()
|
||||
.chain(¶meters.args)
|
||||
.chain(¶meters.kwonlyargs)
|
||||
.any(|arg| arg.parameter.name.as_str() == name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if let Some(arg) = ¶meters.vararg {
|
||||
if arg.name.as_str() == name {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if let Some(arg) = ¶meters.kwarg {
|
||||
if arg.name.as_str() == name {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// Given an [`Expr`] that can be callable or not (like a decorator, which could
|
||||
/// be used with or without explicit call syntax), return the underlying
|
||||
/// callable.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue