Skip to content

Commit 7e4a0be

Browse files
author
Hugo Osvaldo Barrera
committed
Upgrade flake8
Update to the latest flake8, and fix all code warnings related to that.
1 parent aafafaa commit 7e4a0be

File tree

9 files changed

+42
-38
lines changed

9 files changed

+42
-38
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ install-test: install-servers
8282
[ -z "$(TEST_EXTRA_PACKAGES)" ] || pip install $(TEST_EXTRA_PACKAGES)
8383

8484
install-style: install-docs
85-
pip install -U flake8==3.5.0 flake8-import-order 'flake8-bugbear>=17.3.0' autopep8
85+
pip install -U flake8 flake8-import-order flake8-bugbear autopep8
8686

8787
style:
8888
flake8

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ addopts = --tb=short
99
# E731: Use a def instead of lambda expr
1010
# E743: Ambiguous function definition
1111
ignore = E731, E743
12+
# E503: Line break occurred before a binary operator
13+
extend-ignore = W503
1214
select = C,E,F,W,B,B9
1315
exclude = .eggs, tests/storage/servers/owncloud/, tests/storage/servers/nextcloud/, tests/storage/servers/baikal/, build/
1416
application-package-names = tests,vdirsyncer

tests/storage/dav/test_caldav.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ def test_item_types_general(self, s):
140140
task = s.upload(format_item(TASK_TEMPLATE))[0]
141141
s.item_types = ('VTODO', 'VEVENT')
142142

143-
def l():
144-
return set(href for href, etag in s.list())
143+
def hrefs():
144+
return {href for href, etag in s.list()}
145145

146-
assert l() == {event, task}
146+
assert hrefs() == {event, task}
147147
s.item_types = ('VTODO',)
148-
assert l() == {task}
148+
assert hrefs() == {task}
149149
s.item_types = ('VEVENT',)
150-
assert l() == {event}
150+
assert hrefs() == {event}
151151
s.item_types = ()
152-
assert l() == {event, task}
152+
assert hrefs() == {event, task}

tests/storage/test_filesystem.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ def test_post_hook_active(self, tmpdir, monkeypatch):
6767
calls = []
6868
exe = 'foo'
6969

70-
def check_call_mock(l, *args, **kwargs):
70+
def check_call_mock(call, *args, **kwargs):
7171
calls.append(True)
72-
assert len(l) == 2
73-
assert l[0] == exe
72+
assert len(call) == 2
73+
assert call[0] == exe
7474

7575
monkeypatch.setattr(subprocess, 'call', check_call_mock)
7676

@@ -82,5 +82,5 @@ def test_ignore_git_dirs(self, tmpdir):
8282
tmpdir.mkdir('.git').mkdir('foo')
8383
tmpdir.mkdir('a')
8484
tmpdir.mkdir('b')
85-
assert set(c['collection'] for c
86-
in self.storage_class.discover(str(tmpdir))) == {'a', 'b'}
85+
assert {c['collection'] for c
86+
in self.storage_class.discover(str(tmpdir))} == {'a', 'b'}

tests/unit/utils/test_vobject.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
]
2323

2424
_simple_joined = u'\r\n'.join(
25-
[u'BEGIN:VADDRESSBOOK'] +
26-
_simple_split +
27-
[u'END:VADDRESSBOOK\r\n']
25+
[u'BEGIN:VADDRESSBOOK']
26+
+ _simple_split
27+
+ [u'END:VADDRESSBOOK\r\n']
2828
)
2929

3030

@@ -40,9 +40,9 @@ def test_split_collection_simple(benchmark):
4040

4141
def test_split_collection_multiple_wrappers(benchmark):
4242
joined = u'\r\n'.join(
43-
u'BEGIN:VADDRESSBOOK\r\n' +
44-
x +
45-
u'\r\nEND:VADDRESSBOOK\r\n'
43+
u'BEGIN:VADDRESSBOOK\r\n'
44+
+ x
45+
+ u'\r\nEND:VADDRESSBOOK\r\n'
4646
for x in _simple_split
4747
)
4848
given = benchmark(lambda: list(vobject.split_collection(joined)))
@@ -118,19 +118,19 @@ def test_split_collection_timezones():
118118
)
119119

120120
full = u'\r\n'.join(
121-
[u'BEGIN:VCALENDAR'] +
122-
items +
123-
[timezone, u'END:VCALENDAR']
121+
[u'BEGIN:VCALENDAR']
122+
+ items
123+
+ [timezone, u'END:VCALENDAR']
124124
)
125125

126-
given = set(normalize_item(item)
127-
for item in vobject.split_collection(full))
128-
expected = set(
126+
given = {normalize_item(item)
127+
for item in vobject.split_collection(full)}
128+
expected = {
129129
normalize_item(u'\r\n'.join((
130130
u'BEGIN:VCALENDAR', item, timezone, u'END:VCALENDAR'
131131
)))
132132
for item in items
133-
)
133+
}
134134

135135
assert given == expected
136136

vdirsyncer/cli/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _validate_collections_param(collections):
6464
e = ValueError(
6565
'Expected list of format '
6666
'["config_name", "storage_a_name", "storage_b_name"]'
67-
.format(len(collection)))
67+
)
6868
if len(collection) != 3:
6969
raise e
7070

vdirsyncer/storage/singlefile.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ def discover(cls, path, **kwargs):
7070
args['path'] = subpath
7171

7272
collection_end = (
73-
placeholder_pos +
74-
2 + # length of '%s'
75-
len(subpath) - len(path)
73+
placeholder_pos
74+
+ 2 # length of '%s'
75+
+ len(subpath)
76+
- len(path)
7677
)
7778
collection = subpath[placeholder_pos:collection_end]
7879
args['collection'] = collection
@@ -162,10 +163,11 @@ def delete(self, href, etag):
162163
def _write(self):
163164
if self._last_etag is not None and \
164165
self._last_etag != get_etag_from_file(self.path):
165-
raise exceptions.PreconditionFailed(
166-
'Some other program modified the file {r!}. Re-run the '
166+
raise exceptions.PreconditionFailed((
167+
'Some other program modified the file {!r}. Re-run the '
167168
'synchronization and make sure absolutely no other program is '
168-
'writing into the same file.'.format(self.path))
169+
'writing into the same file.'
170+
).format(self.path))
169171
text = join_collection(
170172
item.raw for item, etag in self._items.values()
171173
)

vdirsyncer/sync/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ def is_changed(self, ident):
7474
new_meta = self.status.get_new(ident)
7575

7676
return (
77-
new_meta.etag != old_meta.etag and # etag changed
77+
new_meta.etag != old_meta.etag # etag changed
7878
# item actually changed
79-
(old_meta.hash is None or new_meta.hash != old_meta.hash)
79+
and (old_meta.hash is None or new_meta.hash != old_meta.hash)
8080
)
8181

8282
def set_item_cache(self, ident, item):

vdirsyncer/vobject.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ def get(self, key, default=None):
375375

376376
def __eq__(self, other):
377377
return (
378-
isinstance(other, type(self)) and
379-
self.name == other.name and
380-
self.props == other.props and
381-
self.subcomponents == other.subcomponents
378+
isinstance(other, type(self))
379+
and self.name == other.name
380+
and self.props == other.props
381+
and self.subcomponents == other.subcomponents
382382
)

0 commit comments

Comments
 (0)