title: How to fix "TypeError: 'dict' object is not callable" in requests
body: <p>My goal for this code is to send an email using Mailgun. I'm using calling it from Flask using the <code>requests</code> library:</p>
  
  <p><strong>contact.py</strong></p>
  
  <pre><code>def index():
    data = request.form.to_dict()
    send_email(data)
    return "Success!"
  </code></pre>
  
  <p><strong>send_email()</strong></p>
  
  <pre><code>def send_email(data: dict):
    data = format_data(data)
  
    return requests.post(
      API_URL,
      auth={ "api": API_KEY },
      data=data,
    )
  </code></pre>
  
  <p>I know it has something to do with the <code>send_email()</code> function but I'm currently stuck at how to solve it.</p>
  
  <hr>
  
  <p><strong>EDIT</strong>: Here's the full traceback:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/flask/app.py", line 1982, in wsgi_app
      response = self.full_dispatch_request()
    File "/usr/lib/python3/dist-packages/flask/app.py", line 1614, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File "/usr/lib/python3/dist-packages/flask/app.py", line 1517, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File "/usr/lib/python3/dist-packages/flask/_compat.py", line 33, in reraise
      raise value
    File "/usr/lib/python3/dist-packages/flask/app.py", line 1612, in full_dispatch_request
      rv = self.dispatch_request()
    File "/usr/lib/python3/dist-packages/flask/app.py", line 1598, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File "contact.py", line 9, in index
      send_email(data)
    File "/home/david-hermes/Desktop/Projects/frontend/web/single-page-resume/send_email.py", line 44, in send_email
      data=data,
    File "/usr/lib/python3/dist-packages/requests/api.py", line 112, in post
      return request('post', url, data=data, json=json, **kwargs)
    File "/usr/lib/python3/dist-packages/requests/api.py", line 58, in request
      return session.request(method=method, url=url, **kwargs)
    File "/usr/lib/python3/dist-packages/requests/sessions.py", line 494, in request
      prep = self.prepare_request(req)
    File "/usr/lib/python3/dist-packages/requests/sessions.py", line 437, in prepare_request
      hooks=merge_hooks(request.hooks, self.hooks),
    File "/usr/lib/python3/dist-packages/requests/models.py", line 309, in prepare
      self.prepare_auth(auth, url)
    File "/usr/lib/python3/dist-packages/requests/models.py", line 540, in prepare_auth
      r = auth(self)
  TypeError: 'dict' object is not callable
  127.0.0.1 - - [31/Jan/2019 21:01:28] "POST / HTTP/1.1" 500 -
  </code></pre>