Skip to content

Commit ef912bb

Browse files
committed
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
1 parent b30f040 commit ef912bb

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎crates/ruff/tests/cli/lint.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4872,6 +4872,7 @@ fn default_rules() -> Result<()> {
48724872
f-string-in-get-text-func-call (INT001),
48734873
format-in-get-text-func-call (INT002),
48744874
printf-in-get-text-func-call (INT003),
4875+
implicit-string-concatenation-in-collection-literal (ISC004),
48754876
direct-logger-instantiation (LOG001),
48764877
invalid-get-logger-argument (LOG002),
48774878
undocumented-warn (LOG009),
@@ -5035,6 +5036,7 @@ fn default_rules() -> Result<()> {
50355036
nonlocal-without-binding (PLE0117),
50365037
load-before-global-declaration (PLE0118),
50375038
invalid-length-return-type (PLE0303),
5039+
invalid-bool-return-type (PLE0304),
50385040
invalid-index-return-type (PLE0305),
50395041
invalid-str-return-type (PLE0307),
50405042
invalid-bytes-return-type (PLE0308),
@@ -5065,6 +5067,7 @@ fn default_rules() -> Result<()> {
50655067
property-with-parameters (PLR0206),
50665068
manual-from-import (PLR0402),
50675069
redefined-argument-from-local (PLR1704),
5070+
stop-iteration-return (PLR1708),
50685071
useless-return (PLR1711),
50695072
boolean-chained-comparison (PLR1716),
50705073
sys-exit-alias (PLR1722),
@@ -5150,6 +5153,7 @@ fn default_rules() -> Result<()> {
51505153
implicit-cwd (FURB177),
51515154
hashlib-digest-hex (FURB181),
51525155
slice-to-remove-prefix-or-suffix (FURB188),
5156+
sorted-min-max (FURB192),
51535157
zip-instead-of-pairwise (RUF007),
51545158
mutable-dataclass-default (RUF008),
51555159
function-call-in-dataclass-default-argument (RUF009),
@@ -5181,6 +5185,8 @@ fn default_rules() -> Result<()> {
51815185
unnecessary-round (RUF057),
51825186
starmap-zip (RUF058),
51835187
unused-unpacked-variable (RUF059),
5188+
access-annotations-from-class-dict (RUF063),
5189+
duplicate-entry-in-dunder-all (RUF068),
51845190
unused-noqa (RUF100),
51855191
redirected-noqa (RUF101),
51865192
invalid-pyproject-toml (RUF200),

‎crates/ruff/tests/cli/snapshots/cli__show_settings__display_default_settings.snap‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ linter.rules.enabled = [
158158
f-string-in-get-text-func-call (INT001),
159159
format-in-get-text-func-call (INT002),
160160
printf-in-get-text-func-call (INT003),
161+
implicit-string-concatenation-in-collection-literal (ISC004),
161162
direct-logger-instantiation (LOG001),
162163
invalid-get-logger-argument (LOG002),
163164
undocumented-warn (LOG009),
@@ -321,6 +322,7 @@ linter.rules.enabled = [
321322
nonlocal-without-binding (PLE0117),
322323
load-before-global-declaration (PLE0118),
323324
invalid-length-return-type (PLE0303),
325+
invalid-bool-return-type (PLE0304),
324326
invalid-index-return-type (PLE0305),
325327
invalid-str-return-type (PLE0307),
326328
invalid-bytes-return-type (PLE0308),
@@ -351,6 +353,7 @@ linter.rules.enabled = [
351353
property-with-parameters (PLR0206),
352354
manual-from-import (PLR0402),
353355
redefined-argument-from-local (PLR1704),
356+
stop-iteration-return (PLR1708),
354357
useless-return (PLR1711),
355358
boolean-chained-comparison (PLR1716),
356359
sys-exit-alias (PLR1722),
@@ -436,6 +439,7 @@ linter.rules.enabled = [
436439
implicit-cwd (FURB177),
437440
hashlib-digest-hex (FURB181),
438441
slice-to-remove-prefix-or-suffix (FURB188),
442+
sorted-min-max (FURB192),
439443
zip-instead-of-pairwise (RUF007),
440444
mutable-dataclass-default (RUF008),
441445
function-call-in-dataclass-default-argument (RUF009),
@@ -467,6 +471,8 @@ linter.rules.enabled = [
467471
unnecessary-round (RUF057),
468472
starmap-zip (RUF058),
469473
unused-unpacked-variable (RUF059),
474+
access-annotations-from-class-dict (RUF063),
475+
duplicate-entry-in-dunder-all (RUF068),
470476
unused-noqa (RUF100),
471477
redirected-noqa (RUF101),
472478
invalid-pyproject-toml (RUF200),
@@ -567,6 +573,7 @@ linter.rules.should_fix = [
567573
f-string-in-get-text-func-call (INT001),
568574
format-in-get-text-func-call (INT002),
569575
printf-in-get-text-func-call (INT003),
576+
implicit-string-concatenation-in-collection-literal (ISC004),
570577
direct-logger-instantiation (LOG001),
571578
invalid-get-logger-argument (LOG002),
572579
undocumented-warn (LOG009),
@@ -730,6 +737,7 @@ linter.rules.should_fix = [
730737
nonlocal-without-binding (PLE0117),
731738
load-before-global-declaration (PLE0118),
732739
invalid-length-return-type (PLE0303),
740+
invalid-bool-return-type (PLE0304),
733741
invalid-index-return-type (PLE0305),
734742
invalid-str-return-type (PLE0307),
735743
invalid-bytes-return-type (PLE0308),
@@ -760,6 +768,7 @@ linter.rules.should_fix = [
760768
property-with-parameters (PLR0206),
761769
manual-from-import (PLR0402),
762770
redefined-argument-from-local (PLR1704),
771+
stop-iteration-return (PLR1708),
763772
useless-return (PLR1711),
764773
boolean-chained-comparison (PLR1716),
765774
sys-exit-alias (PLR1722),
@@ -845,6 +854,7 @@ linter.rules.should_fix = [
845854
implicit-cwd (FURB177),
846855
hashlib-digest-hex (FURB181),
847856
slice-to-remove-prefix-or-suffix (FURB188),
857+
sorted-min-max (FURB192),
848858
zip-instead-of-pairwise (RUF007),
849859
mutable-dataclass-default (RUF008),
850860
function-call-in-dataclass-default-argument (RUF009),
@@ -876,6 +886,8 @@ linter.rules.should_fix = [
876886
unnecessary-round (RUF057),
877887
starmap-zip (RUF058),
878888
unused-unpacked-variable (RUF059),
889+
access-annotations-from-class-dict (RUF063),
890+
duplicate-entry-in-dunder-all (RUF068),
879891
unused-noqa (RUF100),
880892
redirected-noqa (RUF101),
881893
invalid-pyproject-toml (RUF200),

‎crates/ruff_linter/src/settings/mod.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ pub const DEFAULT_SELECTORS: &[RuleSelector] = &[
487487
RuleSelector::rule(Rule::ImplicitCwd), // FURB177
488488
RuleSelector::rule(Rule::HashlibDigestHex), // FURB181
489489
RuleSelector::rule(Rule::SliceToRemovePrefixOrSuffix), // FURB188
490+
RuleSelector::rule(Rule::SortedMinMax), // FURB192
490491
RuleSelector::rule(Rule::LoggingWarn), // G010
491492
RuleSelector::rule(Rule::LoggingExtraAttrClash), // G101
492493
RuleSelector::rule(Rule::LoggingExcInfo), // G201
@@ -495,6 +496,7 @@ pub const DEFAULT_SELECTORS: &[RuleSelector] = &[
495496
RuleSelector::rule(Rule::FStringInGetTextFuncCall), // INT001
496497
RuleSelector::rule(Rule::FormatInGetTextFuncCall), // INT002
497498
RuleSelector::rule(Rule::PrintfInGetTextFuncCall), // INT003
499+
RuleSelector::rule(Rule::ImplicitStringConcatenationInCollectionLiteral), // ISC004
498500
RuleSelector::rule(Rule::DirectLoggerInstantiation), // LOG001
499501
RuleSelector::rule(Rule::InvalidGetLoggerArgument), // LOG002
500502
RuleSelector::rule(Rule::UndocumentedWarn), // LOG009
@@ -528,6 +530,7 @@ pub const DEFAULT_SELECTORS: &[RuleSelector] = &[
528530
RuleSelector::rule(Rule::NonlocalWithoutBinding), // PLE0117
529531
RuleSelector::rule(Rule::LoadBeforeGlobalDeclaration), // PLE0118
530532
RuleSelector::rule(Rule::InvalidLengthReturnType), // PLE0303
533+
RuleSelector::rule(Rule::InvalidBoolReturnType), // PLE0304
531534
RuleSelector::rule(Rule::InvalidIndexReturnType), // PLE0305
532535
RuleSelector::rule(Rule::InvalidStrReturnType), // PLE0307
533536
RuleSelector::rule(Rule::InvalidBytesReturnType), // PLE0308
@@ -558,6 +561,7 @@ pub const DEFAULT_SELECTORS: &[RuleSelector] = &[
558561
RuleSelector::rule(Rule::PropertyWithParameters), // PLR0206
559562
RuleSelector::rule(Rule::ManualFromImport), // PLR0402
560563
RuleSelector::rule(Rule::RedefinedArgumentFromLocal), // PLR1704
564+
RuleSelector::rule(Rule::StopIterationReturn), // PLR1708
561565
RuleSelector::rule(Rule::UselessReturn), // PLR1711
562566
RuleSelector::rule(Rule::BooleanChainedComparison), // PLR1716
563567
RuleSelector::rule(Rule::SysExitAlias), // PLR1722
@@ -672,6 +676,8 @@ pub const DEFAULT_SELECTORS: &[RuleSelector] = &[
672676
RuleSelector::rule(Rule::UnnecessaryRound), // RUF057
673677
RuleSelector::rule(Rule::StarmapZip), // RUF058
674678
RuleSelector::rule(Rule::UnusedUnpackedVariable), // RUF059
679+
RuleSelector::rule(Rule::AccessAnnotationsFromClassDict), // RUF063
680+
RuleSelector::rule(Rule::DuplicateEntryInDunderAll), // RUF068
675681
RuleSelector::rule(Rule::UnusedNOQA), // RUF100
676682
RuleSelector::rule(Rule::RedirectedNOQA), // RUF101
677683
RuleSelector::rule(Rule::InvalidPyprojectToml), // RUF200

0 commit comments

Comments
 (0)