Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid flagging bad-dunder-method-name for _ #8015

Merged
merged 1 commit into from Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -68,6 +68,10 @@ def __html__(self):
def _missing_(cls, value):
pass

# Allow anonymous functions.
def _(self):
pass


def __foo_bar__(): # this is not checked by the [bad-dunder-name] rule
...
Expand Up @@ -54,7 +54,7 @@ pub(crate) fn bad_dunder_method_name(checker: &mut Checker, class_body: &[Stmt])
.iter()
.filter_map(ruff_python_ast::Stmt::as_function_def_stmt)
.filter(|method| {
if is_known_dunder_method(&method.name) {
if is_known_dunder_method(&method.name) || matches!(method.name.as_str(), "_") {
return false;
}
method.name.starts_with('_') && method.name.ends_with('_')
Expand Down