old_contents: from invoke import run
  from invoke import task
  
  
  @task
  def clean(docs=False, bytecode=True, extra=''):
      patterns = ['build']
      if docs:
          patterns.append('docs/_build')
      if bytecode:
          patterns.append('**/*.pyc')
      if extra:
          patterns.append(extra)
      for pattern in patterns:
          run("rm -rf %s" % pattern)
  
  
  @task
  def build(docs=False):
      run("python setup.py build")
      if docs:
          run("sphinx-build docs docs/_build")
  
  
  @task
  def test():
      run("python setup.py test")
  
  
  @task
  def lint():
      run("flake8")
  
new_contents: from invoke import run
  from invoke import task
  
  
  @task
  def clean(all=False):
      if all:
          flag = "--all"
      else:
          flag = ""
      run("python setup.py clean {}".format(flag))
  
  
  @task
  def build(docs=False):
      run("python setup.py build")
      if docs:
          run("sphinx-build docs docs/_build")
  
  
  @task
  def test():
      run("python setup.py test")
  
  
  @task
  def lint():
      run("flake8")
  
subject: Change clean task to use setup.py