fix_ne.py 571 B

1234567891011121314151617181920212223
  1. # Copyright 2006 Google, Inc. All Rights Reserved.
  2. # Licensed to PSF under a Contributor Agreement.
  3. """Fixer that turns <> into !=."""
  4. # Local imports
  5. from .. import pytree
  6. from ..pgen2 import token
  7. from .. import fixer_base
  8. class FixNe(fixer_base.BaseFix):
  9. # This is so simple that we don't need the pattern compiler.
  10. _accept_type = token.NOTEQUAL
  11. def match(self, node):
  12. # Override
  13. return node.value == "<>"
  14. def transform(self, node, results):
  15. new = pytree.Leaf(token.NOTEQUAL, "!=", prefix=node.prefix)
  16. return new