title: UnboundLocalError at / local variable 'key' referenced before assignment
body: <p>here is my code i am facing this error i am  not able to find the error fix the error shoow</p>
  <pre><code>def get_key(res_by):
      if res_by == '#1':
          key = 'transaction_id'
      elif res_by == '#2':
          key = 'created'
      return key
  def get_chart(chart_type, data, results_by, **kwargs):
          plt.switch_backend('AGG')
          fig = plt.figure(figsize=(10,4))
          key = get_key(results_by)
          
  </code></pre>
  <p>thats the code</p>