fix_remove_old__future__imports.py 851 B

1234567891011121314151617181920212223242526
  1. """
  2. Fixer for removing any of these lines:
  3. from __future__ import with_statement
  4. from __future__ import nested_scopes
  5. from __future__ import generators
  6. The reason is that __future__ imports like these are required to be the first
  7. line of code (after docstrings) on Python 2.6+, which can get in the way.
  8. These imports are always enabled in Python 2.6+, which is the minimum sane
  9. version to target for Py2/3 compatibility.
  10. """
  11. from lib2to3 import fixer_base
  12. from libfuturize.fixer_util import remove_future_import
  13. class FixRemoveOldFutureImports(fixer_base.BaseFix):
  14. BM_compatible = True
  15. PATTERN = "file_input"
  16. run_order = 1
  17. def transform(self, node, results):
  18. remove_future_import(u"with_statement", node)
  19. remove_future_import(u"nested_scopes", node)
  20. remove_future_import(u"generators", node)