Skip to content

Commit

Permalink
[flake8-bugbear] Allow pathlib.Path() in B008
Browse files Browse the repository at this point in the history
`pathlib.Path()` is immutable.

ref: astral-sh#3762
  • Loading branch information
rouge8 committed Mar 29, 2023
1 parent 595cd06 commit b268f0d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from decimal import Decimal
import logging
import operator
from pathlib import Path
import random
import re
import time
Expand Down Expand Up @@ -182,6 +183,10 @@ def datetime_okay(value=dt.datetime(2023, 3, 27, 13, 51, 59)):
def timedelta_okay(value=dt.timedelta(hours=1)):
pass

# Allow paths
def path_okay(value=Path(".")):
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 @@ -39,6 +39,7 @@ const IMMUTABLE_FUNCS: &[&[&str]] = &[
&["operator", "attrgetter"],
&["operator", "itemgetter"],
&["operator", "methodcaller"],
&["pathlib", "Path"],
&["types", "MappingProxyType"],
&["re", "compile"],
];
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: 61
row: 62
column: 24
end_location:
row: 61
row: 62
column: 33
fix:
edits: []
Expand All @@ -22,10 +22,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 65
row: 66
column: 29
end_location:
row: 65
row: 66
column: 31
fix:
edits: []
Expand All @@ -36,10 +36,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 69
row: 70
column: 19
end_location:
row: 69
row: 70
column: 24
fix:
edits: []
Expand All @@ -50,10 +50,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 73
row: 74
column: 19
end_location:
row: 73
row: 74
column: 44
fix:
edits: []
Expand All @@ -64,10 +64,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 77
row: 78
column: 31
end_location:
row: 77
row: 78
column: 56
fix:
edits: []
Expand All @@ -78,10 +78,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 81
row: 82
column: 25
end_location:
row: 81
row: 82
column: 44
fix:
edits: []
Expand All @@ -92,10 +92,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 86
row: 87
column: 45
end_location:
row: 86
row: 87
column: 69
fix:
edits: []
Expand All @@ -106,10 +106,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 90
row: 91
column: 45
end_location:
row: 90
row: 91
column: 72
fix:
edits: []
Expand All @@ -120,10 +120,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 94
row: 95
column: 44
end_location:
row: 94
row: 95
column: 68
fix:
edits: []
Expand All @@ -134,10 +134,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 98
row: 99
column: 32
end_location:
row: 98
row: 99
column: 34
fix:
edits: []
Expand All @@ -148,10 +148,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 187
row: 192
column: 19
end_location:
row: 187
row: 192
column: 48
fix:
edits: []
Expand All @@ -162,10 +162,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 220
row: 225
column: 26
end_location:
row: 220
row: 225
column: 28
fix:
edits: []
Expand All @@ -176,10 +176,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 221
row: 226
column: 34
end_location:
row: 221
row: 226
column: 36
fix:
edits: []
Expand All @@ -190,10 +190,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 222
row: 227
column: 61
end_location:
row: 222
row: 227
column: 66
fix:
edits: []
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: 86
row: 87
column: 60
end_location:
row: 86
row: 87
column: 68
fix:
edits: []
Expand All @@ -22,10 +22,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 90
row: 91
column: 63
end_location:
row: 90
row: 91
column: 71
fix:
edits: []
Expand All @@ -36,10 +36,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 94
row: 95
column: 59
end_location:
row: 94
row: 95
column: 67
fix:
edits: []
Expand All @@ -50,10 +50,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 110
row: 111
column: 38
end_location:
row: 110
row: 111
column: 49
fix:
edits: []
Expand All @@ -64,10 +64,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 114
row: 115
column: 11
end_location:
row: 114
row: 115
column: 28
fix:
edits: []
Expand All @@ -78,10 +78,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 118
row: 119
column: 29
end_location:
row: 118
row: 119
column: 44
fix:
edits: []
Expand All @@ -92,10 +92,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 156
row: 157
column: 33
end_location:
row: 156
row: 157
column: 47
fix:
edits: []
Expand All @@ -106,10 +106,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 161
row: 162
column: 29
end_location:
row: 161
row: 162
column: 37
fix:
edits: []
Expand All @@ -120,10 +120,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 165
row: 166
column: 44
end_location:
row: 165
row: 166
column: 57
fix:
edits: []
Expand All @@ -134,10 +134,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 187
row: 192
column: 20
end_location:
row: 187
row: 192
column: 28
fix:
edits: []
Expand All @@ -148,10 +148,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 187
row: 192
column: 30
end_location:
row: 187
row: 192
column: 47
fix:
edits: []
Expand All @@ -162,10 +162,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 193
row: 198
column: 21
end_location:
row: 193
row: 198
column: 62
fix:
edits: []
Expand All @@ -176,10 +176,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 198
row: 203
column: 18
end_location:
row: 198
row: 203
column: 59
fix:
edits: []
Expand All @@ -190,10 +190,10 @@ expression: diagnostics
suggestion: ~
fixable: false
location:
row: 198
row: 203
column: 36
end_location:
row: 198
row: 203
column: 53
fix:
edits: []
Expand Down

0 comments on commit b268f0d

Please sign in to comment.