I'm in the process of removing Python 2 support for many of my projects and I'd like to remove the Python 2 cruft that has build up over the years. I'm talking, for example, about the
# -*- coding: utf-8 -*-
headers, the object specification in
class Foobar(object):
# ...
or the imports from __future__ and six.
How can I best find/remove those things?
The pyupgrade tool does a great job of removing old cruft you no longer need. It supports upgrading to either Python 3+, 3.6+, or 3.7+, removing more and more cruft the newer version you can require.
The pyupgrade readme has an overview of what it fixes, which includes the coding header, the object superclass, unneeded __future__ imports, and many uses of the six library.
Notably, it does not remove the use of the future library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With