mirror of
https://github.com/astral-sh/ruff.git
synced 2026-10-28 10:45:37 +08:00
Add newly stabilized rules to defaults (#27055)
Summary -- I did a quick pass over the newly stabilized rules to see if any of them should be on by default, with these results: | Rule | Category | |--|--| | [PLR1708](https://docs.astral.sh/ruff/rules/PLR1708) | correctness | | [RUF068](https://docs.astral.sh/ruff/rules/RUF068) | correctness | | [ISC004](https://docs.astral.sh/ruff/rules/ISC004) | suspicious | | [PLE0304](https://docs.astral.sh/ruff/rules/PLE0304) | suspicious | | [RUF063](https://docs.astral.sh/ruff/rules/RUF063) | suspicious | | [FURB192](https://docs.astral.sh/ruff/rules/FURB192) | complexity | | [AIR303](https://docs.astral.sh/ruff/rules/AIR303) | pedantic | | [CPY001](https://docs.astral.sh/ruff/rules/CPY001) | pedantic | | [FURB164](https://docs.astral.sh/ruff/rules/FURB164) | pedantic | | [LOG004](https://docs.astral.sh/ruff/rules/LOG004) | pedantic | | [PLR0917](https://docs.astral.sh/ruff/rules/PLR0917) | pedantic | | [RUF036](https://docs.astral.sh/ruff/rules/RUF036) | pedantic | | [RUF045](https://docs.astral.sh/ruff/rules/RUF045) | pedantic | Obviously the categories themselves are still unused for now, but this suggested adding the first six to the default set. I initially included RUF036 in Style and RUF045 as Suspicious but Codex talked me down. LOG004 would also likely be higher if it were a bit more reliable, but we can't easily detect some cases that are relatively common in the ecosystem, such as defining some kind of custom logging function that itself is intended to be called from an exception handler. Test Plan -- Updated snapshots
This commit is contained in:
1 parent
b30f040232
commit
ef912bbbe4
3 files changed
+24
No files matched your search
@@ -4872,6 +4872,7 @@ fn default_rules() -> Result<()> {
|
||||
f-string-in-get-text-func-call (INT001),
|
||||
format-in-get-text-func-call (INT002),
|
||||
printf-in-get-text-func-call (INT003),
|
||||
implicit-string-concatenation-in-collection-literal (ISC004),
|
||||
direct-logger-instantiation (LOG001),
|
||||
invalid-get-logger-argument (LOG002),
|
||||
undocumented-warn (LOG009),
|
||||
@@ -5035,6 +5036,7 @@ fn default_rules() -> Result<()> {
|
||||
nonlocal-without-binding (PLE0117),
|
||||
load-before-global-declaration (PLE0118),
|
||||
invalid-length-return-type (PLE0303),
|
||||
invalid-bool-return-type (PLE0304),
|
||||
invalid-index-return-type (PLE0305),
|
||||
invalid-str-return-type (PLE0307),
|
||||
invalid-bytes-return-type (PLE0308),
|
||||
@@ -5065,6 +5067,7 @@ fn default_rules() -> Result<()> {
|
||||
property-with-parameters (PLR0206),
|
||||
manual-from-import (PLR0402),
|
||||
redefined-argument-from-local (PLR1704),
|
||||
stop-iteration-return (PLR1708),
|
||||
useless-return (PLR1711),
|
||||
boolean-chained-comparison (PLR1716),
|
||||
sys-exit-alias (PLR1722),
|
||||
@@ -5150,6 +5153,7 @@ fn default_rules() -> Result<()> {
|
||||
implicit-cwd (FURB177),
|
||||
hashlib-digest-hex (FURB181),
|
||||
slice-to-remove-prefix-or-suffix (FURB188),
|
||||
sorted-min-max (FURB192),
|
||||
zip-instead-of-pairwise (RUF007),
|
||||
mutable-dataclass-default (RUF008),
|
||||
function-call-in-dataclass-default-argument (RUF009),
|
||||
@@ -5181,6 +5185,8 @@ fn default_rules() -> Result<()> {
|
||||
unnecessary-round (RUF057),
|
||||
starmap-zip (RUF058),
|
||||
unused-unpacked-variable (RUF059),
|
||||
access-annotations-from-class-dict (RUF063),
|
||||
duplicate-entry-in-dunder-all (RUF068),
|
||||
unused-noqa (RUF100),
|
||||
redirected-noqa (RUF101),
|
||||
invalid-pyproject-toml (RUF200),
|
||||
|
||||
@@ -158,6 +158,7 @@ linter.rules.enabled = [
|
||||
f-string-in-get-text-func-call (INT001),
|
||||
format-in-get-text-func-call (INT002),
|
||||
printf-in-get-text-func-call (INT003),
|
||||
implicit-string-concatenation-in-collection-literal (ISC004),
|
||||
direct-logger-instantiation (LOG001),
|
||||
invalid-get-logger-argument (LOG002),
|
||||
undocumented-warn (LOG009),
|
||||
@@ -321,6 +322,7 @@ linter.rules.enabled = [
|
||||
nonlocal-without-binding (PLE0117),
|
||||
load-before-global-declaration (PLE0118),
|
||||
invalid-length-return-type (PLE0303),
|
||||
invalid-bool-return-type (PLE0304),
|
||||
invalid-index-return-type (PLE0305),
|
||||
invalid-str-return-type (PLE0307),
|
||||
invalid-bytes-return-type (PLE0308),
|
||||
@@ -351,6 +353,7 @@ linter.rules.enabled = [
|
||||
property-with-parameters (PLR0206),
|
||||
manual-from-import (PLR0402),
|
||||
redefined-argument-from-local (PLR1704),
|
||||
stop-iteration-return (PLR1708),
|
||||
useless-return (PLR1711),
|
||||
boolean-chained-comparison (PLR1716),
|
||||
sys-exit-alias (PLR1722),
|
||||
@@ -436,6 +439,7 @@ linter.rules.enabled = [
|
||||
implicit-cwd (FURB177),
|
||||
hashlib-digest-hex (FURB181),
|
||||
slice-to-remove-prefix-or-suffix (FURB188),
|
||||
sorted-min-max (FURB192),
|
||||
zip-instead-of-pairwise (RUF007),
|
||||
mutable-dataclass-default (RUF008),
|
||||
function-call-in-dataclass-default-argument (RUF009),
|
||||
@@ -467,6 +471,8 @@ linter.rules.enabled = [
|
||||
unnecessary-round (RUF057),
|
||||
starmap-zip (RUF058),
|
||||
unused-unpacked-variable (RUF059),
|
||||
access-annotations-from-class-dict (RUF063),
|
||||
duplicate-entry-in-dunder-all (RUF068),
|
||||
unused-noqa (RUF100),
|
||||
redirected-noqa (RUF101),
|
||||
invalid-pyproject-toml (RUF200),
|
||||
@@ -567,6 +573,7 @@ linter.rules.should_fix = [
|
||||
f-string-in-get-text-func-call (INT001),
|
||||
format-in-get-text-func-call (INT002),
|
||||
printf-in-get-text-func-call (INT003),
|
||||
implicit-string-concatenation-in-collection-literal (ISC004),
|
||||
direct-logger-instantiation (LOG001),
|
||||
invalid-get-logger-argument (LOG002),
|
||||
undocumented-warn (LOG009),
|
||||
@@ -730,6 +737,7 @@ linter.rules.should_fix = [
|
||||
nonlocal-without-binding (PLE0117),
|
||||
load-before-global-declaration (PLE0118),
|
||||
invalid-length-return-type (PLE0303),
|
||||
invalid-bool-return-type (PLE0304),
|
||||
invalid-index-return-type (PLE0305),
|
||||
invalid-str-return-type (PLE0307),
|
||||
invalid-bytes-return-type (PLE0308),
|
||||
@@ -760,6 +768,7 @@ linter.rules.should_fix = [
|
||||
property-with-parameters (PLR0206),
|
||||
manual-from-import (PLR0402),
|
||||
redefined-argument-from-local (PLR1704),
|
||||
stop-iteration-return (PLR1708),
|
||||
useless-return (PLR1711),
|
||||
boolean-chained-comparison (PLR1716),
|
||||
sys-exit-alias (PLR1722),
|
||||
@@ -845,6 +854,7 @@ linter.rules.should_fix = [
|
||||
implicit-cwd (FURB177),
|
||||
hashlib-digest-hex (FURB181),
|
||||
slice-to-remove-prefix-or-suffix (FURB188),
|
||||
sorted-min-max (FURB192),
|
||||
zip-instead-of-pairwise (RUF007),
|
||||
mutable-dataclass-default (RUF008),
|
||||
function-call-in-dataclass-default-argument (RUF009),
|
||||
@@ -876,6 +886,8 @@ linter.rules.should_fix = [
|
||||
unnecessary-round (RUF057),
|
||||
starmap-zip (RUF058),
|
||||
unused-unpacked-variable (RUF059),
|
||||
access-annotations-from-class-dict (RUF063),
|
||||
duplicate-entry-in-dunder-all (RUF068),
|
||||
unused-noqa (RUF100),
|
||||
redirected-noqa (RUF101),
|
||||
invalid-pyproject-toml (RUF200),
|
||||
|
||||
@@ -487,6 +487,7 @@ pub const DEFAULT_SELECTORS: &[RuleSelector] = &[
|
||||
RuleSelector::rule(Rule::ImplicitCwd), // FURB177
|
||||
RuleSelector::rule(Rule::HashlibDigestHex), // FURB181
|
||||
RuleSelector::rule(Rule::SliceToRemovePrefixOrSuffix), // FURB188
|
||||
RuleSelector::rule(Rule::SortedMinMax), // FURB192
|
||||
RuleSelector::rule(Rule::LoggingWarn), // G010
|
||||
RuleSelector::rule(Rule::LoggingExtraAttrClash), // G101
|
||||
RuleSelector::rule(Rule::LoggingExcInfo), // G201
|
||||
@@ -495,6 +496,7 @@ pub const DEFAULT_SELECTORS: &[RuleSelector] = &[
|
||||
RuleSelector::rule(Rule::FStringInGetTextFuncCall), // INT001
|
||||
RuleSelector::rule(Rule::FormatInGetTextFuncCall), // INT002
|
||||
RuleSelector::rule(Rule::PrintfInGetTextFuncCall), // INT003
|
||||
RuleSelector::rule(Rule::ImplicitStringConcatenationInCollectionLiteral), // ISC004
|
||||
RuleSelector::rule(Rule::DirectLoggerInstantiation), // LOG001
|
||||
RuleSelector::rule(Rule::InvalidGetLoggerArgument), // LOG002
|
||||
RuleSelector::rule(Rule::UndocumentedWarn), // LOG009
|
||||
@@ -528,6 +530,7 @@ pub const DEFAULT_SELECTORS: &[RuleSelector] = &[
|
||||
RuleSelector::rule(Rule::NonlocalWithoutBinding), // PLE0117
|
||||
RuleSelector::rule(Rule::LoadBeforeGlobalDeclaration), // PLE0118
|
||||
RuleSelector::rule(Rule::InvalidLengthReturnType), // PLE0303
|
||||
RuleSelector::rule(Rule::InvalidBoolReturnType), // PLE0304
|
||||
RuleSelector::rule(Rule::InvalidIndexReturnType), // PLE0305
|
||||
RuleSelector::rule(Rule::InvalidStrReturnType), // PLE0307
|
||||
RuleSelector::rule(Rule::InvalidBytesReturnType), // PLE0308
|
||||
@@ -558,6 +561,7 @@ pub const DEFAULT_SELECTORS: &[RuleSelector] = &[
|
||||
RuleSelector::rule(Rule::PropertyWithParameters), // PLR0206
|
||||
RuleSelector::rule(Rule::ManualFromImport), // PLR0402
|
||||
RuleSelector::rule(Rule::RedefinedArgumentFromLocal), // PLR1704
|
||||
RuleSelector::rule(Rule::StopIterationReturn), // PLR1708
|
||||
RuleSelector::rule(Rule::UselessReturn), // PLR1711
|
||||
RuleSelector::rule(Rule::BooleanChainedComparison), // PLR1716
|
||||
RuleSelector::rule(Rule::SysExitAlias), // PLR1722
|
||||
@@ -672,6 +676,8 @@ pub const DEFAULT_SELECTORS: &[RuleSelector] = &[
|
||||
RuleSelector::rule(Rule::UnnecessaryRound), // RUF057
|
||||
RuleSelector::rule(Rule::StarmapZip), // RUF058
|
||||
RuleSelector::rule(Rule::UnusedUnpackedVariable), // RUF059
|
||||
RuleSelector::rule(Rule::AccessAnnotationsFromClassDict), // RUF063
|
||||
RuleSelector::rule(Rule::DuplicateEntryInDunderAll), // RUF068
|
||||
RuleSelector::rule(Rule::UnusedNOQA), // RUF100
|
||||
RuleSelector::rule(Rule::RedirectedNOQA), // RUF101
|
||||
RuleSelector::rule(Rule::InvalidPyprojectToml), // RUF200
|
||||
|
||||
Reference in new issue
Block a user