Skip to content

Commit

Permalink
[flake8-bugbear] Allow decimal.Decimal in a function argument defau…
Browse files Browse the repository at this point in the history
…lts for B008

ref: astral-sh#3762
  • Loading branch information
rouge8 committed Mar 27, 2023
1 parent 0eb5a22 commit 582b401
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import collections
import datetime as dt
from decimal import Decimal
import logging
import operator
import random
Expand Down Expand Up @@ -165,6 +166,11 @@ def float_str_not_inf_or_nan_is_wrong(value=float("3.14")):
pass


# Allow decimals
def decimal_okay(value=Decimal("0.1")):
pass


# B006 and B008
# We should handle arbitrary nesting of these B008.
def nested_combo(a=[float(3), dt.datetime.now()]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl Violation for FunctionCallInDefaultArgument {
const IMMUTABLE_FUNCS: &[&[&str]] = &[
&["", "tuple"],
&["", "frozenset"],
&["decimal", "Decimal"],
&["operator", "attrgetter"],
&["operator", "itemgetter"],
&["operator", "methodcaller"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 60
row: 61
column: 24
end_location:
row: 60
row: 61
column: 33
fix:
edits: []
Expand All @@ -22,10 +22,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 64
row: 65
column: 29
end_location:
row: 64
row: 65
column: 31
fix:
edits: []
Expand All @@ -36,10 +36,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 68
row: 69
column: 19
end_location:
row: 68
row: 69
column: 24
fix:
edits: []
Expand All @@ -50,10 +50,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 72
row: 73
column: 19
end_location:
row: 72
row: 73
column: 44
fix:
edits: []
Expand All @@ -64,10 +64,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 76
row: 77
column: 31
end_location:
row: 76
row: 77
column: 56
fix:
edits: []
Expand All @@ -78,10 +78,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 80
row: 81
column: 25
end_location:
row: 80
row: 81
column: 44
fix:
edits: []
Expand All @@ -92,10 +92,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 85
row: 86
column: 45
end_location:
row: 85
row: 86
column: 69
fix:
edits: []
Expand All @@ -106,10 +106,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 89
row: 90
column: 45
end_location:
row: 89
row: 90
column: 72
fix:
edits: []
Expand All @@ -120,10 +120,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 93
row: 94
column: 44
end_location:
row: 93
row: 94
column: 68
fix:
edits: []
Expand All @@ -134,10 +134,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 97
row: 98
column: 32
end_location:
row: 97
row: 98
column: 34
fix:
edits: []
Expand All @@ -148,10 +148,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 170
row: 176
column: 19
end_location:
row: 170
row: 176
column: 48
fix:
edits: []
Expand All @@ -162,10 +162,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 203
row: 209
column: 26
end_location:
row: 203
row: 209
column: 28
fix:
edits: []
Expand All @@ -176,10 +176,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 204
row: 210
column: 34
end_location:
row: 204
row: 210
column: 36
fix:
edits: []
Expand All @@ -190,10 +190,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 205
row: 211
column: 61
end_location:
row: 205
row: 211
column: 66
fix:
edits: []
Expand Down
Loading

0 comments on commit 582b401

Please sign in to comment.