mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Ignore more rules for stub files (#14541)
This PR causes the following rules to ignore stub files, on the grounds that it is not under the author's control to appease these lints: - `PLR0904` https://docs.astral.sh/ruff/rules/too-many-public-methods/ - `PLR0913` https://docs.astral.sh/ruff/rules/too-many-arguments/ - `PLR0917` https://docs.astral.sh/ruff/rules/too-many-positional-arguments/ - `PLW3201` https://docs.astral.sh/ruff/rules/bad-dunder-method-name/ - `SLOT` https://docs.astral.sh/ruff/rules/#flake8-slots-slot - `FBT` https://docs.astral.sh/ruff/rules/#flake8-boolean-trap-fbt (except for FBT003 since that involves a function call.) Progress towards #14535
This commit is contained in:
parent
4ba847f250
commit
e1838aac29
9 changed files with 36 additions and 0 deletions
|
@ -106,6 +106,10 @@ pub(crate) fn boolean_default_value_positional_argument(
|
|||
decorator_list: &[Decorator],
|
||||
parameters: &Parameters,
|
||||
) {
|
||||
// https://github.com/astral-sh/ruff/issues/14535
|
||||
if checker.source_type.is_stub() {
|
||||
return;
|
||||
}
|
||||
// Allow Boolean defaults in explicitly-allowed functions.
|
||||
if is_allowed_func_def(name) {
|
||||
return;
|
||||
|
|
|
@ -115,6 +115,10 @@ pub(crate) fn boolean_type_hint_positional_argument(
|
|||
decorator_list: &[Decorator],
|
||||
parameters: &Parameters,
|
||||
) {
|
||||
// https://github.com/astral-sh/ruff/issues/14535
|
||||
if checker.source_type.is_stub() {
|
||||
return;
|
||||
}
|
||||
// Allow Boolean type hints in explicitly-allowed functions.
|
||||
if is_allowed_func_def(name) {
|
||||
return;
|
||||
|
|
|
@ -78,6 +78,10 @@ pub(crate) fn no_slots_in_namedtuple_subclass(
|
|||
stmt: &Stmt,
|
||||
class: &StmtClassDef,
|
||||
) {
|
||||
// https://github.com/astral-sh/ruff/issues/14535
|
||||
if checker.source_type.is_stub() {
|
||||
return;
|
||||
}
|
||||
let Some(Arguments { args: bases, .. }) = class.arguments.as_deref() else {
|
||||
return;
|
||||
};
|
||||
|
|
|
@ -50,6 +50,10 @@ impl Violation for NoSlotsInStrSubclass {
|
|||
|
||||
/// SLOT000
|
||||
pub(crate) fn no_slots_in_str_subclass(checker: &mut Checker, stmt: &Stmt, class: &StmtClassDef) {
|
||||
// https://github.com/astral-sh/ruff/issues/14535
|
||||
if checker.source_type.is_stub() {
|
||||
return;
|
||||
}
|
||||
let Some(Arguments { args: bases, .. }) = class.arguments.as_deref() else {
|
||||
return;
|
||||
};
|
||||
|
|
|
@ -51,6 +51,10 @@ impl Violation for NoSlotsInTupleSubclass {
|
|||
|
||||
/// SLOT001
|
||||
pub(crate) fn no_slots_in_tuple_subclass(checker: &mut Checker, stmt: &Stmt, class: &StmtClassDef) {
|
||||
// https://github.com/astral-sh/ruff/issues/14535
|
||||
if checker.source_type.is_stub() {
|
||||
return;
|
||||
}
|
||||
let Some(Arguments { args: bases, .. }) = class.arguments.as_deref() else {
|
||||
return;
|
||||
};
|
||||
|
|
|
@ -57,6 +57,10 @@ impl Violation for BadDunderMethodName {
|
|||
|
||||
/// PLW3201
|
||||
pub(crate) fn bad_dunder_method_name(checker: &mut Checker, method: &ast::StmtFunctionDef) {
|
||||
// https://github.com/astral-sh/ruff/issues/14535
|
||||
if checker.source_type.is_stub() {
|
||||
return;
|
||||
}
|
||||
// If the name isn't a dunder, skip it.
|
||||
if !method.name.starts_with('_') || !method.name.ends_with('_') {
|
||||
return;
|
||||
|
|
|
@ -59,6 +59,10 @@ impl Violation for TooManyArguments {
|
|||
|
||||
/// PLR0913
|
||||
pub(crate) fn too_many_arguments(checker: &mut Checker, function_def: &ast::StmtFunctionDef) {
|
||||
// https://github.com/astral-sh/ruff/issues/14535
|
||||
if checker.source_type.is_stub() {
|
||||
return;
|
||||
}
|
||||
let semantic = checker.semantic();
|
||||
|
||||
let num_arguments = function_def
|
||||
|
|
|
@ -60,6 +60,10 @@ pub(crate) fn too_many_positional_arguments(
|
|||
checker: &mut Checker,
|
||||
function_def: &ast::StmtFunctionDef,
|
||||
) {
|
||||
// https://github.com/astral-sh/ruff/issues/14535
|
||||
if checker.source_type.is_stub() {
|
||||
return;
|
||||
}
|
||||
let semantic = checker.semantic();
|
||||
|
||||
// Count the number of positional arguments.
|
||||
|
|
|
@ -105,6 +105,10 @@ pub(crate) fn too_many_public_methods(
|
|||
class_def: &ast::StmtClassDef,
|
||||
max_methods: usize,
|
||||
) {
|
||||
// https://github.com/astral-sh/ruff/issues/14535
|
||||
if checker.source_type.is_stub() {
|
||||
return;
|
||||
}
|
||||
let methods = class_def
|
||||
.body
|
||||
.iter()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue