jeremyephron / simplegmail

A simple Gmail API client for applications in Python
MIT License
339 stars 73 forks source link

TypeError: sum() takes no keyword arguments #21

Closed xinjin95 closed 3 years ago

xinjin95 commented 3 years ago

@jeremyephron Thanks for your efforts on this great api.

I got an error while retrieving unread emails with the following code:

messages = gmail.get_unread_inbox()

Then I got the following error messages:

Traceback (most recent call last):
  File "/home/xxx/simple-gmail-test.py", line 34, in <module>
    messages = gmail.get_unread_inbox()
  File "/home/xxx/.local/lib/python3.6/site-packages/simplegmail/gmail.py", line 190, in get_unread_inbox
    return self.get_unread_messages(user_id, labels, query)
  File "/home/xxx/.local/lib/python3.6/site-packages/simplegmail/gmail.py", line 307, in get_unread_messages
    include_spam_trash)
  File "/home/xxx/.local/lib/python3.6/site-packages/simplegmail/gmail.py", line 525, in get_messages
    attachments)
  File "/home/xxx/.local/lib/python3.6/site-packages/simplegmail/gmail.py", line 632, in _get_messages_from_refs
    return sum(message_lists, start=[])
TypeError: sum() takes no keyword arguments

While tracking data flow of the internal functions, I found everything is good before the return statement of _get_messages_from_refs function. Moreover, I am using Python 3.6.9.

Do you have any ideas about this issue?

jeremyephron commented 3 years ago

@xinjin95 Yes it seems that start as a keyword was added to the sum() function in Python 3.8. For the time being, I am committed to making this 3.6 compatible, so I will fix the bug and upload a new version of the package. If you can't wait, you can either upgrade to Python3.8 or edit the gmail.py file, line 632 and delete start= (that's the whole fix!).

I will post again when the fix has been uploaded.

xinjin95 commented 3 years ago

Sounds great, thanks!

jeremyephron commented 3 years ago

@xinjin95, the fix has been uploaded. You can run

python3 -m pip install --upgrade simplegmail

to update to the newest version.

Run

python3 -m pip show simplegmail

to confirm that the version number is 3.1.1.