mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 12:29:28 +00:00
Add convenience helper methods for AST nodes representing function parameters (#15871)
This commit is contained in:
parent
bcdb3f9840
commit
d9a1034db0
36 changed files with 150 additions and 238 deletions
|
@ -1,6 +1,7 @@
|
|||
//! Analysis rules for the `typing` module.
|
||||
|
||||
use ruff_python_ast::helpers::{any_over_expr, is_const_false, map_subscript};
|
||||
use ruff_python_ast::identifier::Identifier;
|
||||
use ruff_python_ast::name::QualifiedName;
|
||||
use ruff_python_ast::{
|
||||
self as ast, Expr, ExprCall, Int, Operator, ParameterWithDefault, Parameters, Stmt, StmtAssign,
|
||||
|
@ -617,7 +618,7 @@ fn check_type<T: TypeChecker>(binding: &Binding, semantic: &SemanticModel) -> bo
|
|||
let Some(parameter) = find_parameter(parameters, binding) else {
|
||||
return false;
|
||||
};
|
||||
let Some(ref annotation) = parameter.parameter.annotation else {
|
||||
let Some(annotation) = parameter.annotation() else {
|
||||
return false;
|
||||
};
|
||||
T::match_annotation(annotation, semantic)
|
||||
|
@ -1026,7 +1027,7 @@ fn find_parameter<'a>(
|
|||
) -> Option<&'a ParameterWithDefault> {
|
||||
parameters
|
||||
.iter_non_variadic_params()
|
||||
.find(|arg| arg.parameter.name.range() == binding.range())
|
||||
.find(|param| param.identifier() == binding.range())
|
||||
}
|
||||
|
||||
/// Return the [`QualifiedName`] of the value to which the given [`Expr`] is assigned, if any.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue