Skip to content

Coding Styles


  • Line length: Maximum of 119 rather than usual 79. That said, where possible keep it between 79-99 to keep it readable.
  • Indent: 4 spaces, no tabs.
  • All code should use 'single quotes'.


Deluge follows PEP8 and Python Code Style with line length the only exception.

flake8 deluge
isort -rc -df deluge
pylint deluge
pylint deluge/plugins/*/deluge/
  • Using the pre-commit app can aid in picking up issues before creating git commits.

  • All byte strings (str) should be decoded to strings (unicode strings, unicode) on input and encoded back to byte strings on output. From Stackoverflow:

>>> b"abcde"
>>> b"abcde".decode("utf-8")

Notes: * *PyGTK/GTK+ will accept str (utf8 encoded) or unicode but will only return str. See GTK+ Unicode docs. *

  • *There is also a bytearray type which enables in-place modification of a string. See Python Bytearrays *

  • *For reference Python 3 renames unicode to str type and byte strings become bytes type. *

  • All relative path separators used within code should be converted to posix format /, so should not contain \ or \\. This is to prevent confusion when dealing with cross-platform clients and servers.


You will find a mix of the older reStructuredText and newer, easier to read, Sphinx Napoleon format.

Going forward the Napoleon Google Style will be used for all new doctrings and eventually convert over the rest.

Google Style short example:

def func(arg):
   """Function purpose.

       arg (type): Description.

      type: Description. If the line is too, long indent next
         line with three spaces.


Most common sections are Args and Returns. See complete list of supported headers.

Verify that the documentation parses correctly with:

python build_docs

Python References

Useful links to style guides from other projects:


Using codepainter with hautelook style will ensure a consistent coding style.

codepaint xform -p hautelook "file.js"
  • Classes should follow the Ext coding style.
  • Class names should be in CamelCase
  • Instances of classes should use camelCase.