- 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'.
- Code must pass flake8 (w/flake8-quotes), isort and Pylint source code checkers.
flake8 deluge isort -rc -df deluge pylint deluge pylint deluge/plugins/*/deluge/
- Using the pre-common 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' >>> b"abcde".decode("utf-8") 'abcde'Notes:
- 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.
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. Args: arg (type): Description. Returns: 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 setup.py build_docs
Useful links to style guides from other projects:
- CKAN Python coding standards
- Google Python Style Guide
- Best of the Best Practices Guide for Python
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.