Remove several incorrect uses of map_callable() (#12580)

This commit is contained in:
Alex Waygood 2024-07-30 14:30:25 +01:00 committed by GitHub
parent 459c85ba27
commit ac1666d6e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -28,23 +28,23 @@ pub fn is_classmethod(decorator_list: &[Decorator], semantic: &SemanticModel) ->
/// Returns `true` if a function definition is an `@overload`. /// Returns `true` if a function definition is an `@overload`.
pub fn is_overload(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool { pub fn is_overload(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool {
decorator_list.iter().any(|decorator| { decorator_list
semantic.match_typing_expr(map_callable(&decorator.expression), "overload") .iter()
}) .any(|decorator| semantic.match_typing_expr(&decorator.expression, "overload"))
} }
/// Returns `true` if a function definition is an `@override` (PEP 698). /// Returns `true` if a function definition is an `@override` (PEP 698).
pub fn is_override(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool { pub fn is_override(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool {
decorator_list.iter().any(|decorator| { decorator_list
semantic.match_typing_expr(map_callable(&decorator.expression), "override") .iter()
}) .any(|decorator| semantic.match_typing_expr(&decorator.expression, "override"))
} }
/// Returns `true` if a function definition is an abstract method based on its decorators. /// Returns `true` if a function definition is an abstract method based on its decorators.
pub fn is_abstract(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool { pub fn is_abstract(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool {
decorator_list.iter().any(|decorator| { decorator_list.iter().any(|decorator| {
semantic semantic
.resolve_qualified_name(map_callable(&decorator.expression)) .resolve_qualified_name(&decorator.expression)
.is_some_and(|qualified_name| { .is_some_and(|qualified_name| {
matches!( matches!(
qualified_name.segments(), qualified_name.segments(),
@ -86,7 +86,7 @@ pub fn is_property(
pub fn is_final(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool { pub fn is_final(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool {
decorator_list decorator_list
.iter() .iter()
.any(|decorator| semantic.match_typing_expr(map_callable(&decorator.expression), "final")) .any(|decorator| semantic.match_typing_expr(&decorator.expression, "final"))
} }
/// Returns `true` if a function is a "magic method". /// Returns `true` if a function is a "magic method".