forked from PyCQA/flake8-bugbear
-
Notifications
You must be signed in to change notification settings - Fork 0
/
b006_b008.py
129 lines (73 loc) · 1.99 KB
/
b006_b008.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import collections
import logging
import operator
import re
import time
import types
from operator import attrgetter, itemgetter, methodcaller
from types import MappingProxyType
def this_is_okay(value=(1, 2, 3)):
...
def and_this_also(value=tuple()):
pass
def frozenset_also_okay(value=frozenset()):
pass
def mappingproxytype_okay(
value=MappingProxyType({}), value2=types.MappingProxyType({})
):
pass
def this_is_wrong(value=[1, 2, 3]):
...
def this_is_also_wrong(value={}):
...
def and_this(value=set()):
...
def this_too(value=collections.OrderedDict()):
...
async def async_this_too(value=collections.OrderedDict()):
...
def do_this_instead(value=None):
if value is None:
value = set()
def in_fact_all_calls_are_wrong(value=time.time()):
...
LOGGER = logging.getLogger(__name__)
def do_this_instead_of_calls_in_defaults(logger=LOGGER):
# That makes it more obvious that this one value is reused.
...
def kwonlyargs_immutable(*, value=()):
...
def kwonlyargs_mutable(*, value=[]):
...
def float_inf_okay(value=float("inf")):
pass
def float_infinity_okay(value=float("infinity")):
pass
def float_plus_infinity_okay(value=float("+infinity")):
pass
def float_minus_inf_okay(value=float("-inf")):
pass
def float_nan_okay(value=float("nan")):
pass
def float_minus_NaN_okay(value=float("-NaN")):
pass
def float_int_is_wrong(value=float(3)):
pass
def float_str_not_inf_or_nan_is_wrong(value=float("3.14")):
pass
def re_compile_ok(value=re.compile("foo")):
pass
def operators_ok(
v=operator.attrgetter("foo"),
v2=operator.itemgetter("foo"),
v3=operator.methodcaller("foo"),
):
pass
def operators_ok_unqualified(
v=attrgetter("foo"), v2=itemgetter("foo"), v3=methodcaller("foo")
):
pass
def list_comprehension_also_not_okay(default=[i ** 2 for i in range(3)]):
pass
def dict_comprehension_also_not_okay(default={i: i ** 2 for i in range(3)}):
pass