diff --git a/Makefile b/Makefile index 9f69944..e862a03 100644 --- a/Makefile +++ b/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 diff --git a/setup.cfg b/setup.cfg index 4635543..ec67785 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/tests/storage/dav/test_caldav.py b/tests/storage/dav/test_caldav.py index 3063bbd..e72dd22 100644 --- a/tests/storage/dav/test_caldav.py +++ b/tests/storage/dav/test_caldav.py @@ -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} diff --git a/tests/storage/test_filesystem.py b/tests/storage/test_filesystem.py index 39a4880..f9f6c83 100644 --- a/tests/storage/test_filesystem.py +++ b/tests/storage/test_filesystem.py @@ -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'} diff --git a/tests/unit/utils/test_vobject.py b/tests/unit/utils/test_vobject.py index cfb52d1..6ebaa04 100644 --- a/tests/unit/utils/test_vobject.py +++ b/tests/unit/utils/test_vobject.py @@ -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 diff --git a/vdirsyncer/cli/config.py b/vdirsyncer/cli/config.py index 87296d9..717eb40 100644 --- a/vdirsyncer/cli/config.py +++ b/vdirsyncer/cli/config.py @@ -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 diff --git a/vdirsyncer/storage/singlefile.py b/vdirsyncer/storage/singlefile.py index 1e13f20..f789ef0 100644 --- a/vdirsyncer/storage/singlefile.py +++ b/vdirsyncer/storage/singlefile.py @@ -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() ) diff --git a/vdirsyncer/sync/__init__.py b/vdirsyncer/sync/__init__.py index e899868..91d04e8 100644 --- a/vdirsyncer/sync/__init__.py +++ b/vdirsyncer/sync/__init__.py @@ -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): diff --git a/vdirsyncer/vobject.py b/vdirsyncer/vobject.py index d97a057..fedf549 100644 --- a/vdirsyncer/vobject.py +++ b/vdirsyncer/vobject.py @@ -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 )