Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 3f568389763c205f8779ad75f2cf44ab9782608e authored by Larry Hastings on 07 August 2017, 07:59:11 UTC
Version bump for 3.5.4 final.
Tip revision: 3f56838
fix_ne.py
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.

"""Fixer that turns <> into !=."""

# Local imports
from .. import pytree
from ..pgen2 import token
from .. import fixer_base


class FixNe(fixer_base.BaseFix):
    # This is so simple that we don't need the pattern compiler.

    _accept_type = token.NOTEQUAL

    def match(self, node):
        # Override
        return node.value == "<>"

    def transform(self, node, results):
        new = pytree.Leaf(token.NOTEQUAL, "!=", prefix=node.prefix)
        return new
back to top