fix_object.py 407 B

1234567891011121314151617
  1. """
  2. Fixer that adds ``from builtins import object`` if there is a line
  3. like this:
  4. class Foo(object):
  5. """
  6. from lib2to3 import fixer_base
  7. from libfuturize.fixer_util import touch_import_top
  8. class FixObject(fixer_base.BaseFix):
  9. PATTERN = u"classdef< 'class' NAME '(' name='object' ')' colon=':' any >"
  10. def transform(self, node, results):
  11. touch_import_top(u'builtins', 'object', node)