File tree Expand file tree Collapse file tree 4 files changed +26
-8
lines changed
Expand file tree Collapse file tree 4 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -253,6 +253,7 @@ Next version
253253~~~~~~~~~~~~
254254
255255* Introduce B016 to check for raising a literal. (#141)
256+ * Exclude types.MappingProxyType() from B008. (#144)
256257
25725820.1.4
258259~~~~~~
Original file line number Diff line number Diff line change @@ -632,7 +632,12 @@ def visit(self, node):
632632 "use that variable as a default value."
633633 )
634634)
635- B008 .immutable_calls = {"tuple" , "frozenset" }
635+ B008 .immutable_calls = {
636+ "tuple" ,
637+ "frozenset" ,
638+ "types.MappingProxyType" ,
639+ "MappingProxyType" ,
640+ }
636641B009 = Error (
637642 message = (
638643 "B009 Do not call getattr with a constant attribute value, "
Original file line number Diff line number Diff line change 11import collections
22import logging
33import time
4+ import types
5+ from types import MappingProxyType
46
57
68def this_is_okay (value = (1 , 2 , 3 )):
@@ -11,6 +13,16 @@ def and_this_also(value=tuple()):
1113 pass
1214
1315
16+ def frozenset_also_okay (value = frozenset ()):
17+ pass
18+
19+
20+ def mappingproxytype_okay (
21+ value = MappingProxyType ({}), value2 = types .MappingProxyType ({})
22+ ):
23+ pass
24+
25+
1426def this_is_wrong (value = [1 , 2 , 3 ]):
1527 ...
1628
Original file line number Diff line number Diff line change @@ -97,13 +97,13 @@ def test_b006_b008(self):
9797 self .assertEqual (
9898 errors ,
9999 self .errors (
100- B006 (14 , 24 ),
101- B006 (18 , 29 ),
102- B006 (22 , 19 ),
103- B006 (26 , 19 ),
104- B006 (30 , 31 ),
105- B008 (39 , 38 ),
106- B006 (55 , 32 ),
100+ B006 (26 , 24 ),
101+ B006 (30 , 29 ),
102+ B006 (34 , 19 ),
103+ B006 (38 , 19 ),
104+ B006 (42 , 31 ),
105+ B008 (51 , 38 ),
106+ B006 (67 , 32 ),
107107 ),
108108 )
109109
You can’t perform that action at this time.
0 commit comments