@@ -226,14 +226,7 @@ def visit_UAdd(self, node):
226
226
227
227
def visit_Call (self , node ):
228
228
if isinstance (node .func , ast .Attribute ):
229
- for bug in (B301 , B302 , B305 ):
230
- if node .func .attr in bug .methods :
231
- call_path = "." .join (self .compose_call_path (node .func .value ))
232
- if call_path not in bug .valid_paths :
233
- self .errors .append (bug (node .lineno , node .col_offset ))
234
- break
235
- else :
236
- self .check_for_b005 (node )
229
+ self .check_for_b005 (node )
237
230
else :
238
231
with suppress (AttributeError , IndexError ):
239
232
if (
@@ -258,25 +251,8 @@ def visit_Call(self, node):
258
251
259
252
self .generic_visit (node )
260
253
261
- def visit_Attribute (self , node ):
262
- call_path = list (self .compose_call_path (node ))
263
- if "." .join (call_path ) == "sys.maxint" :
264
- self .errors .append (B304 (node .lineno , node .col_offset ))
265
- elif len (call_path ) == 2 and call_path [1 ] == "message" :
266
- name = call_path [0 ]
267
- for elem in reversed (self .node_stack [:- 1 ]):
268
- if isinstance (elem , ast .ExceptHandler ) and elem .name == name :
269
- self .errors .append (B306 (node .lineno , node .col_offset ))
270
- break
271
-
272
254
def visit_Assign (self , node ):
273
- if isinstance (self .node_stack [- 2 ], ast .ClassDef ):
274
- # note: by hasattr below we're ignoring starred arguments, slices
275
- # and tuples for simplicity.
276
- assign_targets = {t .id for t in node .targets if hasattr (t , "id" )}
277
- if "__metaclass__" in assign_targets :
278
- self .errors .append (B303 (node .lineno , node .col_offset ))
279
- elif len (node .targets ) == 1 :
255
+ if len (node .targets ) == 1 :
280
256
t = node .targets [0 ]
281
257
if isinstance (t , ast .Attribute ) and isinstance (t .value , ast .Name ):
282
258
if (t .value .id , t .attr ) == ("os" , "environ" ):
@@ -771,60 +747,6 @@ def visit(self, node):
771
747
)
772
748
)
773
749
774
- # Those could be false positives but it's more dangerous to let them slip
775
- # through if they're not.
776
- B301 = Error (
777
- message = (
778
- "B301 Python 3 does not include `.iter*` methods on dictionaries. "
779
- "Remove the `iter` prefix from the method name. For Python 2 "
780
- "compatibility, prefer the Python 3 equivalent unless you expect "
781
- "the size of the container to be large or unbounded. Then use "
782
- "`six.iter*` or `future.utils.iter*`."
783
- )
784
- )
785
- B301 .methods = {"iterkeys" , "itervalues" , "iteritems" , "iterlists" }
786
- B301 .valid_paths = {"six" , "future.utils" , "builtins" }
787
-
788
- B302 = Error (
789
- message = (
790
- "B302 Python 3 does not include `.view*` methods on dictionaries. "
791
- "Remove the `view` prefix from the method name. For Python 2 "
792
- "compatibility, prefer the Python 3 equivalent unless you expect "
793
- "the size of the container to be large or unbounded. Then use "
794
- "`six.view*` or `future.utils.view*`."
795
- )
796
- )
797
- B302 .methods = {"viewkeys" , "viewvalues" , "viewitems" , "viewlists" }
798
- B302 .valid_paths = {"six" , "future.utils" , "builtins" }
799
-
800
- B303 = Error (
801
- message = (
802
- "B303 `__metaclass__` does nothing on Python 3. Use "
803
- "`class MyClass(BaseClass, metaclass=...)`. For Python 2 "
804
- "compatibility, use `six.add_metaclass`."
805
- )
806
- )
807
-
808
- B304 = Error (message = "B304 `sys.maxint` is not a thing on Python 3. Use `sys.maxsize`." )
809
-
810
- B305 = Error (
811
- message = (
812
- "B305 `.next()` is not a thing on Python 3. Use the `next()` "
813
- "builtin. For Python 2 compatibility, use `six.next()`."
814
- )
815
- )
816
- B305 .methods = {"next" }
817
- B305 .valid_paths = {"six" , "future.utils" , "builtins" }
818
-
819
- B306 = Error (
820
- message = (
821
- "B306 `BaseException.message` has been deprecated as of Python "
822
- "2.6 and is removed in Python 3. Use `str(e)` to access the "
823
- "user-readable message. Use `e.args` to access arguments passed "
824
- "to the exception."
825
- )
826
- )
827
-
828
750
# Warnings disabled by default.
829
751
B901 = Error (
830
752
message = (
0 commit comments