mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-09 11:26:00 +00:00
Upgrade flake8
Update to the latest flake8, and fix all code warnings related to that.
This commit is contained in:
parent
aafafaa501
commit
7e4a0be674
9 changed files with 42 additions and 38 deletions
2
Makefile
2
Makefile
|
|
@ -82,7 +82,7 @@ install-test: install-servers
|
|||
[ -z "$(TEST_EXTRA_PACKAGES)" ] || pip install $(TEST_EXTRA_PACKAGES)
|
||||
|
||||
install-style: install-docs
|
||||
pip install -U flake8==3.5.0 flake8-import-order 'flake8-bugbear>=17.3.0' autopep8
|
||||
pip install -U flake8 flake8-import-order flake8-bugbear autopep8
|
||||
|
||||
style:
|
||||
flake8
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ addopts = --tb=short
|
|||
# E731: Use a def instead of lambda expr
|
||||
# E743: Ambiguous function definition
|
||||
ignore = E731, E743
|
||||
# E503: Line break occurred before a binary operator
|
||||
extend-ignore = W503
|
||||
select = C,E,F,W,B,B9
|
||||
exclude = .eggs, tests/storage/servers/owncloud/, tests/storage/servers/nextcloud/, tests/storage/servers/baikal/, build/
|
||||
application-package-names = tests,vdirsyncer
|
||||
|
|
|
|||
|
|
@ -140,13 +140,13 @@ class TestCalDAVStorage(DAVStorageTests):
|
|||
task = s.upload(format_item(TASK_TEMPLATE))[0]
|
||||
s.item_types = ('VTODO', 'VEVENT')
|
||||
|
||||
def l():
|
||||
return set(href for href, etag in s.list())
|
||||
def hrefs():
|
||||
return {href for href, etag in s.list()}
|
||||
|
||||
assert l() == {event, task}
|
||||
assert hrefs() == {event, task}
|
||||
s.item_types = ('VTODO',)
|
||||
assert l() == {task}
|
||||
assert hrefs() == {task}
|
||||
s.item_types = ('VEVENT',)
|
||||
assert l() == {event}
|
||||
assert hrefs() == {event}
|
||||
s.item_types = ()
|
||||
assert l() == {event, task}
|
||||
assert hrefs() == {event, task}
|
||||
|
|
|
|||
|
|
@ -67,10 +67,10 @@ class TestFilesystemStorage(StorageTests):
|
|||
calls = []
|
||||
exe = 'foo'
|
||||
|
||||
def check_call_mock(l, *args, **kwargs):
|
||||
def check_call_mock(call, *args, **kwargs):
|
||||
calls.append(True)
|
||||
assert len(l) == 2
|
||||
assert l[0] == exe
|
||||
assert len(call) == 2
|
||||
assert call[0] == exe
|
||||
|
||||
monkeypatch.setattr(subprocess, 'call', check_call_mock)
|
||||
|
||||
|
|
@ -82,5 +82,5 @@ class TestFilesystemStorage(StorageTests):
|
|||
tmpdir.mkdir('.git').mkdir('foo')
|
||||
tmpdir.mkdir('a')
|
||||
tmpdir.mkdir('b')
|
||||
assert set(c['collection'] for c
|
||||
in self.storage_class.discover(str(tmpdir))) == {'a', 'b'}
|
||||
assert {c['collection'] for c
|
||||
in self.storage_class.discover(str(tmpdir))} == {'a', 'b'}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ _simple_split = [
|
|||
]
|
||||
|
||||
_simple_joined = u'\r\n'.join(
|
||||
[u'BEGIN:VADDRESSBOOK'] +
|
||||
_simple_split +
|
||||
[u'END:VADDRESSBOOK\r\n']
|
||||
[u'BEGIN:VADDRESSBOOK']
|
||||
+ _simple_split
|
||||
+ [u'END:VADDRESSBOOK\r\n']
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -40,9 +40,9 @@ def test_split_collection_simple(benchmark):
|
|||
|
||||
def test_split_collection_multiple_wrappers(benchmark):
|
||||
joined = u'\r\n'.join(
|
||||
u'BEGIN:VADDRESSBOOK\r\n' +
|
||||
x +
|
||||
u'\r\nEND:VADDRESSBOOK\r\n'
|
||||
u'BEGIN:VADDRESSBOOK\r\n'
|
||||
+ x
|
||||
+ u'\r\nEND:VADDRESSBOOK\r\n'
|
||||
for x in _simple_split
|
||||
)
|
||||
given = benchmark(lambda: list(vobject.split_collection(joined)))
|
||||
|
|
@ -118,19 +118,19 @@ def test_split_collection_timezones():
|
|||
)
|
||||
|
||||
full = u'\r\n'.join(
|
||||
[u'BEGIN:VCALENDAR'] +
|
||||
items +
|
||||
[timezone, u'END:VCALENDAR']
|
||||
[u'BEGIN:VCALENDAR']
|
||||
+ items
|
||||
+ [timezone, u'END:VCALENDAR']
|
||||
)
|
||||
|
||||
given = set(normalize_item(item)
|
||||
for item in vobject.split_collection(full))
|
||||
expected = set(
|
||||
given = {normalize_item(item)
|
||||
for item in vobject.split_collection(full)}
|
||||
expected = {
|
||||
normalize_item(u'\r\n'.join((
|
||||
u'BEGIN:VCALENDAR', item, timezone, u'END:VCALENDAR'
|
||||
)))
|
||||
for item in items
|
||||
)
|
||||
}
|
||||
|
||||
assert given == expected
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ def _validate_collections_param(collections):
|
|||
e = ValueError(
|
||||
'Expected list of format '
|
||||
'["config_name", "storage_a_name", "storage_b_name"]'
|
||||
.format(len(collection)))
|
||||
)
|
||||
if len(collection) != 3:
|
||||
raise e
|
||||
|
||||
|
|
|
|||
|
|
@ -70,9 +70,10 @@ class SingleFileStorage(Storage):
|
|||
args['path'] = subpath
|
||||
|
||||
collection_end = (
|
||||
placeholder_pos +
|
||||
2 + # length of '%s'
|
||||
len(subpath) - len(path)
|
||||
placeholder_pos
|
||||
+ 2 # length of '%s'
|
||||
+ len(subpath)
|
||||
- len(path)
|
||||
)
|
||||
collection = subpath[placeholder_pos:collection_end]
|
||||
args['collection'] = collection
|
||||
|
|
@ -162,10 +163,11 @@ class SingleFileStorage(Storage):
|
|||
def _write(self):
|
||||
if self._last_etag is not None and \
|
||||
self._last_etag != get_etag_from_file(self.path):
|
||||
raise exceptions.PreconditionFailed(
|
||||
'Some other program modified the file {r!}. Re-run the '
|
||||
raise exceptions.PreconditionFailed((
|
||||
'Some other program modified the file {!r}. Re-run the '
|
||||
'synchronization and make sure absolutely no other program is '
|
||||
'writing into the same file.'.format(self.path))
|
||||
'writing into the same file.'
|
||||
).format(self.path))
|
||||
text = join_collection(
|
||||
item.raw for item, etag in self._items.values()
|
||||
)
|
||||
|
|
|
|||
|
|
@ -74,9 +74,9 @@ class _StorageInfo(object):
|
|||
new_meta = self.status.get_new(ident)
|
||||
|
||||
return (
|
||||
new_meta.etag != old_meta.etag and # etag changed
|
||||
new_meta.etag != old_meta.etag # etag changed
|
||||
# item actually changed
|
||||
(old_meta.hash is None or new_meta.hash != old_meta.hash)
|
||||
and (old_meta.hash is None or new_meta.hash != old_meta.hash)
|
||||
)
|
||||
|
||||
def set_item_cache(self, ident, item):
|
||||
|
|
|
|||
|
|
@ -375,8 +375,8 @@ class _Component(object):
|
|||
|
||||
def __eq__(self, other):
|
||||
return (
|
||||
isinstance(other, type(self)) and
|
||||
self.name == other.name and
|
||||
self.props == other.props and
|
||||
self.subcomponents == other.subcomponents
|
||||
isinstance(other, type(self))
|
||||
and self.name == other.name
|
||||
and self.props == other.props
|
||||
and self.subcomponents == other.subcomponents
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue