Skip to content

Commit ae07b36

Browse files
committed
Update default rules for v0.17 (#28786)
Summary -- This makes a few modifications to our default rule set for v0.17. As the snapshots show, these had already been incorporated into our preview defaults via rule recategorization. This just ports them back to the stable default rules. This closes #27197, which brought the problems with the DTZ rules to our attention. F406 being a syntax error was raised in [this comment]. [this comment]: #27199 (comment) Test Plan -- Updated snapshots
1 parent a5eb5b4 commit ae07b36

3 files changed

Lines changed: 4 additions & 36 deletions

File tree

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5084,16 +5084,9 @@ fn default_rules() -> Result<()> {
50845084
unnecessary-map (C417),
50855085
unnecessary-literal-within-dict-call (C418),
50865086
unnecessary-comprehension-in-call (C419),
5087-
call-datetime-without-tzinfo (DTZ001),
50885087
call-datetime-today (DTZ002),
50895088
call-datetime-utcnow (DTZ003),
50905089
call-datetime-utcfromtimestamp (DTZ004),
5091-
call-datetime-now-without-tzinfo (DTZ005),
5092-
call-datetime-fromtimestamp (DTZ006),
5093-
call-datetime-strptime-without-zone (DTZ007),
5094-
call-date-today (DTZ011),
5095-
call-date-fromtimestamp (DTZ012),
5096-
datetime-min-max (DTZ901),
50975090
debugger (T100),
50985091
shebang-not-executable (EXE001),
50995092
shebang-missing-executable-file (EXE002),
@@ -5216,6 +5209,7 @@ fn default_rules() -> Result<()> {
52165209
unused-import (F401),
52175210
import-shadowed-by-loop-var (F402),
52185211
late-future-import (F404),
5212+
undefined-local-with-nested-import-star-usage (F406),
52195213
future-feature-not-defined (F407),
52205214
percent-format-invalid-format (F501),
52215215
percent-format-expected-mapping (F502),

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,9 @@ linter.rules.enabled = [
139139
unnecessary-map (C417),
140140
unnecessary-literal-within-dict-call (C418),
141141
unnecessary-comprehension-in-call (C419),
142-
call-datetime-without-tzinfo (DTZ001),
143142
call-datetime-today (DTZ002),
144143
call-datetime-utcnow (DTZ003),
145144
call-datetime-utcfromtimestamp (DTZ004),
146-
call-datetime-now-without-tzinfo (DTZ005),
147-
call-datetime-fromtimestamp (DTZ006),
148-
call-datetime-strptime-without-zone (DTZ007),
149-
call-date-today (DTZ011),
150-
call-date-fromtimestamp (DTZ012),
151-
datetime-min-max (DTZ901),
152145
debugger (T100),
153146
shebang-not-executable (EXE001),
154147
shebang-missing-executable-file (EXE002),
@@ -271,6 +264,7 @@ linter.rules.enabled = [
271264
unused-import (F401),
272265
import-shadowed-by-loop-var (F402),
273266
late-future-import (F404),
267+
undefined-local-with-nested-import-star-usage (F406),
274268
future-feature-not-defined (F407),
275269
percent-format-invalid-format (F501),
276270
percent-format-expected-mapping (F502),
@@ -554,16 +548,9 @@ linter.rules.should_fix = [
554548
unnecessary-map (C417),
555549
unnecessary-literal-within-dict-call (C418),
556550
unnecessary-comprehension-in-call (C419),
557-
call-datetime-without-tzinfo (DTZ001),
558551
call-datetime-today (DTZ002),
559552
call-datetime-utcnow (DTZ003),
560553
call-datetime-utcfromtimestamp (DTZ004),
561-
call-datetime-now-without-tzinfo (DTZ005),
562-
call-datetime-fromtimestamp (DTZ006),
563-
call-datetime-strptime-without-zone (DTZ007),
564-
call-date-today (DTZ011),
565-
call-date-fromtimestamp (DTZ012),
566-
datetime-min-max (DTZ901),
567554
debugger (T100),
568555
shebang-not-executable (EXE001),
569556
shebang-missing-executable-file (EXE002),
@@ -686,6 +673,7 @@ linter.rules.should_fix = [
686673
unused-import (F401),
687674
import-shadowed-by-loop-var (F402),
688675
late-future-import (F404),
676+
undefined-local-with-nested-import-star-usage (F406),
689677
future-feature-not-defined (F407),
690678
percent-format-invalid-format (F501),
691679
percent-format-expected-mapping (F502),

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -413,16 +413,9 @@ pub const DEFAULT_SELECTORS: &[RuleSelector] = &[
413413
RuleSelector::rule(Rule::UnnecessaryLiteralWithinDictCall), // C418
414414
RuleSelector::rule(Rule::UnnecessaryComprehensionInCall), // C419
415415
RuleSelector::rule(Rule::EmptyDocstring), // D419
416-
RuleSelector::rule(Rule::CallDatetimeWithoutTzinfo), // DTZ001
417416
RuleSelector::rule(Rule::CallDatetimeToday), // DTZ002
418417
RuleSelector::rule(Rule::CallDatetimeUtcnow), // DTZ003
419418
RuleSelector::rule(Rule::CallDatetimeUtcfromtimestamp), // DTZ004
420-
RuleSelector::rule(Rule::CallDatetimeNowWithoutTzinfo), // DTZ005
421-
RuleSelector::rule(Rule::CallDatetimeFromtimestamp), // DTZ006
422-
RuleSelector::rule(Rule::CallDatetimeStrptimeWithoutZone), // DTZ007
423-
RuleSelector::rule(Rule::CallDateToday), // DTZ011
424-
RuleSelector::rule(Rule::CallDateFromtimestamp), // DTZ012
425-
RuleSelector::rule(Rule::DatetimeMinMax), // DTZ901
426419
RuleSelector::rule(Rule::BareExcept), // E722
427420
RuleSelector::rule(Rule::IOError), // E902
428421
RuleSelector::rule(Rule::ShebangNotExecutable), // EXE001
@@ -432,6 +425,7 @@ pub const DEFAULT_SELECTORS: &[RuleSelector] = &[
432425
RuleSelector::rule(Rule::UnusedImport), // F401
433426
RuleSelector::rule(Rule::ImportShadowedByLoopVar), // F402
434427
RuleSelector::rule(Rule::LateFutureImport), // F404
428+
RuleSelector::rule(Rule::UndefinedLocalWithNestedImportStarUsage), // F406
435429
RuleSelector::rule(Rule::FutureFeatureNotDefined), // F407
436430
RuleSelector::rule(Rule::PercentFormatInvalidFormat), // F501
437431
RuleSelector::rule(Rule::PercentFormatExpectedMapping), // F502
@@ -1013,7 +1007,6 @@ mod tests {
10131007
pandas-use-of-dot-read-table (PD012),
10141008
pandas-use-of-pd-merge (PD015),
10151009
escape-sequence-in-docstring (D301),
1016-
undefined-local-with-nested-import-star-usage (F406),
10171010
missing-maxsplit-arg (PLC0207),
10181011
unnecessary-dunder-call (PLC2801),
10191012
duplicate-bases (PLE0241),
@@ -1070,13 +1063,6 @@ mod tests {
10701063
Removed in preview:
10711064
[
10721065
exec-builtin (S102),
1073-
call-datetime-without-tzinfo (DTZ001),
1074-
call-datetime-now-without-tzinfo (DTZ005),
1075-
call-datetime-fromtimestamp (DTZ006),
1076-
call-datetime-strptime-without-zone (DTZ007),
1077-
call-date-today (DTZ011),
1078-
call-date-fromtimestamp (DTZ012),
1079-
datetime-min-max (DTZ901),
10801066
]
10811067
");
10821068
}

0 commit comments

Comments
 (0)