Rename semantic_model and model usages to semantic (#5097)

## Summary

As discussed in Discord, and similar to oxc, we're going to refer to
this as `.semantic()` everywhere.

While I was auditing usages of `model: &SemanticModel`, I also changed
as many function signatures as I could find to consistently take the
model as the _last_ argument, rather than the first.
This commit is contained in:
Charlie Marsh 2023-06-14 15:01:51 -04:00 committed by GitHub
parent 65dbfd2556
commit bae183b823
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
209 changed files with 1058 additions and 1167 deletions

View file

@ -14,9 +14,9 @@ pub enum Visibility {
}
/// Returns `true` if a function is a "static method".
pub fn is_staticmethod(model: &SemanticModel, decorator_list: &[Decorator]) -> bool {
pub fn is_staticmethod(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool {
decorator_list.iter().any(|decorator| {
model
semantic
.resolve_call_path(map_callable(&decorator.expression))
.map_or(false, |call_path| {
call_path.as_slice() == ["", "staticmethod"]
@ -25,9 +25,9 @@ pub fn is_staticmethod(model: &SemanticModel, decorator_list: &[Decorator]) -> b
}
/// Returns `true` if a function is a "class method".
pub fn is_classmethod(model: &SemanticModel, decorator_list: &[Decorator]) -> bool {
pub fn is_classmethod(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool {
decorator_list.iter().any(|decorator| {
model
semantic
.resolve_call_path(map_callable(&decorator.expression))
.map_or(false, |call_path| {
call_path.as_slice() == ["", "classmethod"]
@ -36,23 +36,23 @@ pub fn is_classmethod(model: &SemanticModel, decorator_list: &[Decorator]) -> bo
}
/// Returns `true` if a function definition is an `@overload`.
pub fn is_overload(model: &SemanticModel, decorator_list: &[Decorator]) -> bool {
decorator_list
.iter()
.any(|decorator| model.match_typing_expr(map_callable(&decorator.expression), "overload"))
pub fn is_overload(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool {
decorator_list.iter().any(|decorator| {
semantic.match_typing_expr(map_callable(&decorator.expression), "overload")
})
}
/// Returns `true` if a function definition is an `@override` (PEP 698).
pub fn is_override(model: &SemanticModel, decorator_list: &[Decorator]) -> bool {
decorator_list
.iter()
.any(|decorator| model.match_typing_expr(map_callable(&decorator.expression), "override"))
pub fn is_override(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool {
decorator_list.iter().any(|decorator| {
semantic.match_typing_expr(map_callable(&decorator.expression), "override")
})
}
/// Returns `true` if a function definition is an abstract method based on its decorators.
pub fn is_abstract(model: &SemanticModel, decorator_list: &[Decorator]) -> bool {
pub fn is_abstract(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool {
decorator_list.iter().any(|decorator| {
model
semantic
.resolve_call_path(map_callable(&decorator.expression))
.map_or(false, |call_path| {
matches!(
@ -73,12 +73,12 @@ pub fn is_abstract(model: &SemanticModel, decorator_list: &[Decorator]) -> bool
/// `extra_properties` can be used to check additional non-standard
/// `@property`-like decorators.
pub fn is_property(
model: &SemanticModel,
decorator_list: &[Decorator],
extra_properties: &[CallPath],
semantic: &SemanticModel,
) -> bool {
decorator_list.iter().any(|decorator| {
model
semantic
.resolve_call_path(map_callable(&decorator.expression))
.map_or(false, |call_path| {
call_path.as_slice() == ["", "property"]
@ -91,10 +91,10 @@ pub fn is_property(
}
/// Returns `true` if a class is an `final`.
pub fn is_final(model: &SemanticModel, decorator_list: &[Decorator]) -> bool {
pub fn is_final(decorator_list: &[Decorator], semantic: &SemanticModel) -> bool {
decorator_list
.iter()
.any(|decorator| model.match_typing_expr(map_callable(&decorator.expression), "final"))
.any(|decorator| semantic.match_typing_expr(map_callable(&decorator.expression), "final"))
}
/// Returns `true` if a function is a "magic method".