Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Sep 14, 2023
1 parent 3d1ae64 commit 7b1ca54
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions crates/ruff/src/rules/pylint/rules/too_many_public_methods.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use ruff_python_ast::{self as ast, Stmt};

use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast as ast;
use ruff_python_semantic::analyze::visibility::{self, Visibility::Public};
use ruff_text_size::Ranged;

use crate::checkers::ast::Checker;

Expand Down Expand Up @@ -106,12 +106,12 @@ pub(crate) fn too_many_public_methods(
class_def: &ast::StmtClassDef,
max_methods: usize,
) {
let ast::StmtClassDef { body, range, .. } = class_def;
let methods = body
let methods = class_def
.body
.iter()
.filter(|stmt| match stmt {
Stmt::FunctionDef(node) => matches!(visibility::method_visibility(node), Public),
_ => false,
.filter(|stmt| {
stmt.as_function_def_stmt()
.is_some_and(|node| matches!(visibility::method_visibility(node), Public))
})
.count();

Expand All @@ -121,7 +121,7 @@ pub(crate) fn too_many_public_methods(
methods,
max_methods,
},
*range,
class_def.range(),
));
}
}

0 comments on commit 7b1ca54

Please sign in to comment.