mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:24:57 +00:00
[flake8-bugbear
] Allow pathlib.Path()
in B008
(#3794)
This commit is contained in:
parent
595cd065f3
commit
7d962bf80c
4 changed files with 62 additions and 56 deletions
|
@ -3,6 +3,7 @@ import datetime as dt
|
|||
from decimal import Decimal
|
||||
import logging
|
||||
import operator
|
||||
from pathlib import Path
|
||||
import random
|
||||
import re
|
||||
import time
|
||||
|
@ -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()]):
|
||||
|
|
|
@ -39,6 +39,7 @@ const IMMUTABLE_FUNCS: &[&[&str]] = &[
|
|||
&["operator", "attrgetter"],
|
||||
&["operator", "itemgetter"],
|
||||
&["operator", "methodcaller"],
|
||||
&["pathlib", "Path"],
|
||||
&["types", "MappingProxyType"],
|
||||
&["re", "compile"],
|
||||
];
|
||||
|
|
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
|
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue