mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:49:50 +00:00
[flake8-self
] Ignore attribute accesses on instance-like variables (SLF001
) (#16149)
This commit is contained in:
parent
aa88f2dbe5
commit
c814745643
8 changed files with 243 additions and 134 deletions
|
@ -548,6 +548,13 @@ pub fn is_dunder(id: &str) -> bool {
|
|||
id.starts_with("__") && id.ends_with("__")
|
||||
}
|
||||
|
||||
/// Whether a name starts and ends with a single underscore.
|
||||
///
|
||||
/// `_a__` is considered neither a dunder nor a sunder name.
|
||||
pub fn is_sunder(id: &str) -> bool {
|
||||
id.starts_with('_') && id.ends_with('_') && !id.starts_with("__") && !id.ends_with("__")
|
||||
}
|
||||
|
||||
/// Return `true` if the [`Stmt`] is an assignment to a dunder (like `__all__`).
|
||||
pub fn is_assignment_to_a_dunder(stmt: &Stmt) -> bool {
|
||||
// Check whether it's an assignment to a dunder, with or without a type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue