Skip to content

Commit

Permalink
[Lint] Use Black to auto-format code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cas-- committed Oct 3, 2018
1 parent bcca074 commit b1cdc32
Show file tree
Hide file tree
Showing 233 changed files with 9,459 additions and 4,111 deletions.
4 changes: 1 addition & 3 deletions deluge/__rpcapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ class RpcApi(object):


def scan_for_methods(obj):
methods = {
'__doc__': 'Methods available in %s' % obj.__name__.lower(),
}
methods = {'__doc__': 'Methods available in %s' % obj.__name__.lower()}
for d in dir(obj):
if not hasattr(getattr(obj, d), '_rpcserver_export'):
continue
Expand Down
4 changes: 3 additions & 1 deletion deluge/_libtorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@
LT_VERSION = lt.__version__

if VersionSplit(LT_VERSION) < VersionSplit(REQUIRED_VERSION):
raise ImportError('Deluge %s requires libtorrent >= %s' % (get_version(), REQUIRED_VERSION))
raise ImportError(
'Deluge %s requires libtorrent >= %s' % (get_version(), REQUIRED_VERSION)
)
16 changes: 8 additions & 8 deletions deluge/bencode.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,35 @@ def decode_int(x, f):
f += 1
newf = x.index(END_DELIM, f)
n = int(x[f:newf])
if x[f:f + 1] == b'-' and x[f + 1:f + 2] == b'0':
if x[f : f + 1] == b'-' and x[f + 1 : f + 2] == b'0':
raise ValueError
elif x[f:f + 1] == b'0' and newf != f + 1:
elif x[f : f + 1] == b'0' and newf != f + 1:
raise ValueError
return (n, newf + 1)


def decode_string(x, f):
colon = x.index(BYTE_SEP, f)
n = int(x[f:colon])
if x[f:f + 1] == b'0' and colon != f + 1:
if x[f : f + 1] == b'0' and colon != f + 1:
raise ValueError
colon += 1
return (x[colon:colon + n], colon + n)
return (x[colon : colon + n], colon + n)


def decode_list(x, f):
r, f = [], f + 1
while x[f:f + 1] != END_DELIM:
v, f = decode_func[x[f:f + 1]](x, f)
while x[f : f + 1] != END_DELIM:
v, f = decode_func[x[f : f + 1]](x, f)
r.append(v)
return (r, f + 1)


def decode_dict(x, f):
r, f = {}, f + 1
while x[f:f + 1] != END_DELIM:
while x[f : f + 1] != END_DELIM:
k, f = decode_string(x, f)
r[k], f = decode_func[x[f:f + 1]](x, f)
r[k], f = decode_func[x[f : f + 1]](x, f)
return (r, f + 1)


Expand Down
Loading

0 comments on commit b1cdc32

Please sign in to comment.