in contrib/python/src/python/pants/contrib/python/checks/checker/future_compatibility.py [0:0]
def nits(self):
for call in self.iter_ast_types(ast.Call):
if isinstance(call.func, ast.Attribute):
# Not a perfect solution since a user could have a dictionary named six or something similar
# However, this should catch most cases where people are using iter* without six.
if call.func.attr in self.BAD_ITERS and getattr(call.func.value, 'id', '') != 'six':
yield self.error(
'T602',
'{attr} disappears in Python 3.x. Use non-iter instead.'.format(attr=call.func.attr),
call)
elif isinstance(call.func, ast.Name):
if call.func.id in self.BAD_FUNCTIONS:
yield self.error(
'T603',
'Please avoid {func_id} as it disappears in Python 3.x.'.format(func_id=call.func.id),
call)
for name in self.iter_ast_types(ast.Name):
if name.id in self.BAD_NAMES:
yield self.error(
'T604', 'Please avoid {id} as it disappears in Python 3.x.'.format(id=name.id), name)
for class_def in self.iter_ast_types(ast.ClassDef):
for node in class_def.body:
if not isinstance(node, ast.Assign):
continue
for name in node.targets:
if not isinstance(name, ast.Name):
continue
if name.id == '__metaclass__':
yield self.warning('T605',
'This metaclass style is deprecated and gone entirely in Python 3.x.', name)