def transform(self, node, results): func = results['func'] touch_import(None, u'collections', node=node) args = [func.clone(), String(u', ')] args.extend(Attr(Name(u'collections'), Name(u'Callable'))) return Call(Name(u'isinstance'), args, prefix=node.prefix)
def transform(self, node, results): func = results['func'] touch_import(None, u'collections', node=node) args = [func.clone(), String(u', ')] args.extend(Attr(Name(u'collections'), Name(u'Callable'))) return Call(Name(u'isinstance'), args, prefix=node.prefix)
def _handle_type2abc(self, node, results, module, abc): touch_import(None, module, node) obj = results["obj"] args = [obj.clone(), String(u", " + u".".join([module, abc]))] return Call(Name(u"isinstance"), args, prefix=node.prefix)
def transform(self, node, results): touch_import(u'functools', u'reduce', node)
def transform(self, node, results): touch_import(u'functools', u'reduce', node)
def test_name_import(self): node = parse('bar()') fixer_util.touch_import(None, "cgi", node) self.assertEqual(str(node), 'import cgi\nbar()\n\n')
def test_from_import(self): node = parse('bar()') fixer_util.touch_import("html", "escape", node) self.assertEqual(str(node), 'from html import escape\nbar()\n\n')
def test_beginning(self): node = parse('bar()') fixer_util.touch_import(None, "foo", node) self.assertEqual(str(node), 'import foo\nbar()\n\n')
def test_after_imports(self): node = parse('"""foo"""\nimport bar\nbar()') fixer_util.touch_import(None, "foo", node) self.assertEqual(str(node), '"""foo"""\nimport bar\nimport foo\nbar()\n\n')