Changes between Version 23 and Version 24 of Contributing/CodingStyle
- Timestamp:
- 11/13/2016 11:52:03 AM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Contributing/CodingStyle
v23 v24 4 4 5 5 == Common == 6 * Line length: Maximum of `119` rather than usual `79`. That said, where possible keep to `79`.6 * Line length: Maximum of `119` rather than usual `79`. That said, where possible keep it between `79-99` to keep it readable. 7 7 * Indent: `4 spaces`, no tabs. 8 * All code should use `'single quotes'`. 8 9 9 10 == Python == 10 Mostly follow [http://www.python.org/dev/peps/pep-0008/ PEP8] and [http://docs.python-guide.org/en/latest/writing/style/ Python Code Style] with the following exceptions: 11 * Line length ''(see above)'' 11 Deluge follows [http://www.python.org/dev/peps/pep-0008/ PEP8] and [http://docs.python-guide.org/en/latest/writing/style/ Python Code Style] with line length the only exception. 12 12 13 * Code '''must''' pass [https://pypi.python.org/pypi/flake8 flake8] and [http://www.pylint.org/ Pylint] source code checkers.13 * Code '''must''' pass [https://pypi.python.org/pypi/flake8 flake8] (w/[https://pypi.python.org/pypi/flake8-quotes flake8-quotes]), [https://pypi.python.org/pypi/isort isort] and [http://www.pylint.org/ Pylint] source code checkers. 14 14 {{{ 15 15 flake8 deluge 16 isort -rc -df deluge 16 17 pylint deluge 17 18 pylint deluge/plugins/*/deluge/ 18 19 }}} 19 20 20 * All byte arrays (byte strings, `str`) should be decoded to strings (unicode strings, `unicode`) on input and encoded back to byte arrays on output. [http://stackoverflow.com/a/606199/175584 From Stackoverflow:] 21 * Using the [http://pre-commit.com/ pre-common] app can aid in picking up issues before creating git commits. 22 23 * All byte strings (`str`) should be decoded to strings (unicode strings, `unicode`) on input and encoded back to byte strings on output. [http://stackoverflow.com/a/606199/175584 From Stackoverflow:] 21 24 {{{ 22 25 >>> b"abcde" … … 26 29 }}} 27 30 28 **Note:** PyGTK/GTK+ will accept `str` (utf8 encoded) or `unicode` but will only return `str`. See [http://python-gtk-3-tutorial.readthedocs.org/en/latest/unicode.html GTK+ Unicode] docs. 31 **Note1:** PyGTK/GTK+ will accept `str` (utf8 encoded) or `unicode` but will only return `str`. See [http://python-gtk-3-tutorial.readthedocs.org/en/latest/unicode.html GTK+ Unicode] docs. 32 **Note2:** There is also a `bytearray` type which enables in-place modification of a string. See [http://stackoverflow.com/a/9099337/175584 Python Bytearrays] 33 **Note2:** For reference Python 3 renames `unicode` to `str` type and byte arrays becomes `bytes` type. 29 34 30 35 * 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. … … 58 63 }}} 59 64 60 === Single or Double Quotes ===61 62 The python code base should be `"double quotes"`.63 64 65 === Python References === 65 66 … … 80 81 * Class names should be in !CamelCase 81 82 * Instances of classes should use camelCase. 82 83 === Single or Double Quotes ===84 85 For the javascript code use `'single quotes'`.