Adrian Sampson edited this page Apr 7, 2018 · 50 revisions

Porting to Python 3

As of version 1.4, beets supports both Python 3.x and 2.x. Sometime soon, we'll drop support for 2.x.

Coding conventions

  • calls to map() should be wrapped in list() when a list is expected as it returns an iter in python 3

PY3 initial support TODO

  • check documentation for 2.x, 3.x references
  • check wiki for 2.x, 3.x references

PY3 only TODO

  • remove u' (and u") prefixes from code
  • remove u' (and u") prefixes from documentation
  • remove u' (and u") prefixes from wiki
  • delete page
  • run 2to3 to make sure we got everything
  • audit all calls to open() (or any other I/O) to see if we can read/write them as text vs binary
  • remove any PY2/3 version checks and the related code
  • search for all comments with Python 2,Python 3,Python2,Python3,PY2,PY3
  • remove py2 specific tests and packages in .travis.yml
  • remove any usage of six
  • remove # -*- coding: utf-8 -*- from all python files
  • replace buffer with memoryview
  • replace, with open
  • use explicit keyword arg names in function definitions - PY2: def foo(.., **kwargs) -> PY3: def foo(.., arg1=None, arg2=None, ...) as per
  • use str.format style ({}) in beets.logger or drop it completely
  • Remove F405 from flake8 ignore configurtion if beets.logging is replaced
  • change flake8-coding configuration to no-accept-encodings
  • use more 3.x only functions from shutil to replace some of the functions in beets.util (TODO: be more specific)
  • drop mock dep since it's part of the stdlib (py >= 3.3)
  • remove enum34 dep since it's part of the stdlib ( >= 3.4)
  • replace deprecated inspect.getargspec
  • Remove unnecessary traceback passing in HumanReadableException
  • integrate various suggestions from