haystack / YouPS

YouPS: An email automation tool that makes your email management easy! 😎
10 stars 5 forks source link

Moving to Python3 and Deprecated Libraries #28

Open lukesmurray opened 5 years ago

lukesmurray commented 5 years ago

I feel that this project is seriously hampered by being stuck on python2 as well as using deprecated libraries. I was reminded of this fact when I tried to find django documentation for the version of django we are using and realized we are using django 1.6.11 which was released in 2015 and has not had any bug fixes since April 2015.

These are the the up to date versions of the libraries we are using. It might be interesting to try upgrading some of them and seeing if anything breaks.

Some of these are major version changes which means there might be differences in the API. I think we should at least try to keep up with minor version changes though where possible. For example we can try to update to django 1.11 so that we are using the LTS version for python2.

bleach==3.1.0
boto==2.49.0
django-annoying==0.10.4
django-compressor==2.2
django-gravatar==0.1.0
django-mobile==0.7.0
django-registration==3.0
django-storages==1.7.1
dkimpy==0.9.1
flake8==3.7.7
google-api-python-client==1.7.8
html2text==2018.1.9
imapclient==2.1.0
ipaddr==2.2.0
jsonfield==2.0.2
lamson==1.3.4
markdown2==2.3.7
mysql-python==1.2.5
pip-chill==0.1.8
pycrypto==2.6.1
pydns==2.3.6
pyspf==2.0.11
python-gflags==3.1.2
python-gnupg==0.4.4
requests==2.21.0
south==1.0.2

One way we can start to begin the move to python 3 is to start using the from future imports __future__ (print_function, division, absolute_imports, and unicode_literals). Even adding these to one piece of the code base at a time would save a ton of time when moving to python3. Realistically the move to python3 seems unavoidable if this project is going to live longer than the next year.

lukesmurray commented 5 years ago

Some examples of where python3 could be helpful

We have code which returns dictionaries all over the codebase. These could be replaced by named_tuples in python3.

res = {'status' : False, 'imap_error': False, 'imap_log': "", 'imap': None}

The greatest benefit of python3 though would probably be type annotations.

lukesmurray commented 5 years ago

I've started annotating our code with type hints. A cheat sheet for these type hints can be found here but they can be automatically converted to type annotations in python3 and provide autocomplete for python2.