mirror of
https://github.com/astral-sh/ruff
synced 2026-01-24 06:50:59 -05:00
Don't flag B009/B010 if identifiers would be mangled (#2204)
This commit is contained in:
committed by
GitHub
parent
0ad6b8224d
commit
7370a27c09
@@ -13,3 +13,12 @@ pub fn is_identifier(s: &str) -> bool {
|
||||
// Are the rest of the characters letters, digits, or underscores?
|
||||
s.chars().skip(1).all(|c| c.is_alphanumeric() || c == '_')
|
||||
}
|
||||
|
||||
/// Returns `true` if a string is a private identifier, such that, when the
|
||||
/// identifier is defined in a class definition, it will be mangled prior to
|
||||
/// code generation.
|
||||
///
|
||||
/// See: <https://docs.python.org/3.5/reference/expressions.html?highlight=mangling#index-5>.
|
||||
pub fn is_mangled_private(id: &str) -> bool {
|
||||
id.starts_with("__") && !id.ends_with("__")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user