The move to using auto-formatter makes it easier to read, submit and
speeds up development time. https://github.com/ambv/black/
Although I would prefer 79 chars, the default line length of 88 chars
used by black suffices. The flake8 line length remains at 120 chars
since black does not touch comments or docstrings and this will require
another round of fixes.
The only black setting that is not standard is the use of double-quotes
for strings so disabled any formatting of these. Note however that
flake8 will still flag usage of double-quotes. I may change my mind on
double vs single quotes but for now leave them.
A new pyproject.toml file has been created for black configuration.
* A rather disruptive change but for a few reasons such as easier to read,
easier type, keep consistent and javascript code uses single quotes.
* There are a few exceptions for the automated process:
* Any double quotes in comments
* Triple double quotes for docstrings
* Strings containing single quotes are left e.g. "they're"
* To deal with merge conflicts from feature branches it is best to follow
these steps for each commit:
* Create a patch: `git format-patch -1 <sha1>`
* Edit the patch and replace double quotes with single except those in
comments or strings containing an unescaped apostrophe.
* Check the patch `git apply --check <patchfile>` and fix any remaining
issues if it outputs an error.
* Apply the patch `git am < <patchfile>`
* Use print function
* Fix except as statements
* Remove old twisted 8 code
* Remove empty docstring
* Refactor try statement to only contain the relevant import and
disable pylint import msgs.
* Use flake8 noqa and pylint comment and drop pyflakes workarounds.
* Replace the uses of long with int.
* Replace im_func with __func__ as it has been provided for Python 3 forward-compatibility.
* Fix next/__next__ for Python 3 compatibility.
* Remove the long number literal
* Ensure freespace() returns int
To make the code more Python 3 compatible, I've made a few changes to how we handle keys() or iterkeys() calls on dictionaries. All functionality should remain the same.
* Remove the use of .keys() or .iterkeys() when iterating through a dictionary.
* Remove the use of .keys() when checking if key exists in dictionary.
* Replace dict.keys() with list(dict) to obtain a list of dictionary keys. In Python 3 dict.keys() returns a dict_keys object, not a list.
* Ensure all file descriptors are closed. Using the with statement ensures
closure.
* The main problem was with thousands of unclosed file desciptors from
tracker_icons mkstemp.
* Use a prefix 'deluge_ticon.' to identify created tracker_icon tmp files.