mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 04:19:18 +00:00
Rename Arguments
to Parameters
in the AST (#6253)
## Summary This PR renames a few AST nodes for clarity: - `Arguments` is now `Parameters` - `Arg` is now `Parameter` - `ArgWithDefault` is now `ParameterWithDefault` For now, the attribute names that reference `Parameters` directly are changed (e.g., on `StmtFunctionDef`), but the attributes on `Parameters` itself are not (e.g., `vararg`). We may revisit that decision in the future. For context, the AST node formerly known as `Arguments` is used in function definitions. Formally (outside of the Python context), "arguments" typically refers to "the values passed to a function", while "parameters" typically refers to "the variables used in a function definition". E.g., if you Google "arguments vs parameters", you'll get some explanation like: > A parameter is a variable in a function definition. It is a placeholder and hence does not have a concrete value. An argument is a value passed during function invocation. We're thus deviating from Python's nomenclature in favor of a scheme that we find to be more precise.
This commit is contained in:
parent
a82eb9544c
commit
adc8bb7821
102 changed files with 2585 additions and 2529 deletions
|
@ -10,7 +10,7 @@
|
|||
//!
|
||||
//! This module can be used to identify the [`TextRange`] of the `except` token.
|
||||
|
||||
use crate::{self as ast, Alias, Arg, ArgWithDefault, ExceptHandler, Ranged, Stmt};
|
||||
use crate::{self as ast, Alias, ExceptHandler, Parameter, ParameterWithDefault, Ranged, Stmt};
|
||||
use ruff_text_size::{TextLen, TextRange, TextSize};
|
||||
|
||||
use ruff_python_trivia::{is_python_whitespace, Cursor};
|
||||
|
@ -38,8 +38,8 @@ impl Identifier for Stmt {
|
|||
}
|
||||
}
|
||||
|
||||
impl Identifier for Arg {
|
||||
/// Return the [`TextRange`] for the identifier defining an [`Arg`].
|
||||
impl Identifier for Parameter {
|
||||
/// Return the [`TextRange`] for the identifier defining an [`Parameter`].
|
||||
///
|
||||
/// For example, return the range of `x` in:
|
||||
/// ```python
|
||||
|
@ -51,8 +51,8 @@ impl Identifier for Arg {
|
|||
}
|
||||
}
|
||||
|
||||
impl Identifier for ArgWithDefault {
|
||||
/// Return the [`TextRange`] for the identifier defining an [`ArgWithDefault`].
|
||||
impl Identifier for ParameterWithDefault {
|
||||
/// Return the [`TextRange`] for the identifier defining an [`ParameterWithDefault`].
|
||||
///
|
||||
/// For example, return the range of `x` in:
|
||||
/// ```python
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue