from __future__ import unicode_literals
from lib2to3.fixer_base import BaseFix
from lib2to3.pytree import Leaf

SPACES = ' ' * 4

class FixTabs(BaseFix):
    '''
    For new projects, spaces-only are strongly recommended over tabs.  Most
    editors have features that make this easy to do.
    '''

    def match(self, node):
        if node.prefix.count('\t') or (isinstance(node, Leaf)
            and node.value.count('\t')):
            return True
        return False

    def transform(self, node, results):
        new_prefix = node.prefix.replace('\t', SPACES)
        new_value = node.value.replace('\t', SPACES)
        if node.prefix != new_prefix or node.value != new_value:
            node.prefix = new_prefix
            node.value = new_value
            node.changed()

from __future__ import unicode_literals
from lib2to3.fixer_base import BaseFix
from lib2to3.pytree import Leaf

from .utils import SPACES

class FixTabs(BaseFix):
    '''
    For new projects, spaces-only are strongly recommended over tabs.  Most
    editors have features that make this easy to do.
    '''

    def match(self, node):
        if node.prefix.count('\t') or (isinstance(node, Leaf)
            and node.value.count('\t')):
            return True
        return False

    def transform(self, node, results):
        new_prefix = node.prefix.replace('\t', SPACES)
        new_value = node.value.replace('\t', SPACES)
        if node.prefix != new_prefix or node.value != new_value:
            node.prefix = new_prefix
            node.value = new_value
            node.changed()

Use globally define number of spaces.
Clean-up: Use globally define number of spaces.

  from __future__ import unicode_literals
  from lib2to3.fixer_base import BaseFix
  from lib2to3.pytree import Leaf
  
- SPACES = ' ' * 4
+ from .utils import SPACES
  
  class FixTabs(BaseFix):
      '''
      For new projects, spaces-only are strongly recommended over tabs.  Most
      editors have features that make this easy to do.
      '''
  
      def match(self, node):
          if node.prefix.count('\t') or (isinstance(node, Leaf)
              and node.value.count('\t')):
              return True
          return False
  
      def transform(self, node, results):
          new_prefix = node.prefix.replace('\t', SPACES)
          new_value = node.value.replace('\t', SPACES)
          if node.prefix != new_prefix or node.value != new_value:
              node.prefix = new_prefix
              node.value = new_value
              node.changed()
  
Use globally define number of spaces.
## Code Before:
from __future__ import unicode_literals
from lib2to3.fixer_base import BaseFix
from lib2to3.pytree import Leaf

SPACES = ' ' * 4

class FixTabs(BaseFix):
    '''
    For new projects, spaces-only are strongly recommended over tabs.  Most
    editors have features that make this easy to do.
    '''

    def match(self, node):
        if node.prefix.count('\t') or (isinstance(node, Leaf)
            and node.value.count('\t')):
            return True
        return False

    def transform(self, node, results):
        new_prefix = node.prefix.replace('\t', SPACES)
        new_value = node.value.replace('\t', SPACES)
        if node.prefix != new_prefix or node.value != new_value:
            node.prefix = new_prefix
            node.value = new_value
            node.changed()

## Instruction:
Use globally define number of spaces.
## Code After:
from __future__ import unicode_literals
from lib2to3.fixer_base import BaseFix
from lib2to3.pytree import Leaf

from .utils import SPACES

class FixTabs(BaseFix):
    '''
    For new projects, spaces-only are strongly recommended over tabs.  Most
    editors have features that make this easy to do.
    '''

    def match(self, node):
        if node.prefix.count('\t') or (isinstance(node, Leaf)
            and node.value.count('\t')):
            return True
        return False

    def transform(self, node, results):
        new_prefix = node.prefix.replace('\t', SPACES)
        new_value = node.value.replace('\t', SPACES)
        if node.prefix != new_prefix or node.value != new_value:
            node.prefix = new_prefix
            node.value = new_value
            node.changed()
