[flake8-self] Ignore attribute accesses on instance-like variables (SLF001) (#16149)

This commit is contained in:
InSync 2025-02-23 17:00:49 +07:00 committed by GitHub
parent aa88f2dbe5
commit c814745643
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 243 additions and 134 deletions

View file

@ -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