From b1b4dd92feb63a0d6991a5993a47ac6a79300d53 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Tue, 9 Jun 2020 14:34:45 +0200 Subject: [PATCH] Sort imports I don't want to ever have to sort imports again. It's a poor use of developer time. Automate this with a pre-commit hook, and check this on CI. Developers: I suggest you configure your editor to use `reorder_python_imports`. It uses the standard sorting, and detects first/third party libs well. --- .pre-commit-config.yaml | 4 ++++ scripts/make_travisconf.py | 1 - setup.py | 6 +++--- tests/__init__.py | 5 +---- tests/conftest.py | 6 +++--- tests/storage/__init__.py | 18 +++++++++------- tests/storage/conftest.py | 4 ++-- tests/storage/dav/__init__.py | 10 +++------ tests/storage/dav/test_caldav.py | 13 ++++++------ tests/storage/dav/test_carddav.py | 3 +-- tests/storage/dav/test_main.py | 4 +++- .../etesync_server/etesync_server/settings.py | 1 - .../etesync_server/etesync_server/urls.py | 7 +++---- .../etesync_server/etesync_server/wsgi.py | 1 - tests/storage/etesync/test_main.py | 7 +++---- tests/storage/servers/davical/__init__.py | 3 ++- .../storage/servers/mysteryshack/__init__.py | 3 +-- tests/storage/test_filesystem.py | 3 +-- tests/storage/test_http.py | 5 ++--- tests/storage/test_http_with_singlefile.py | 4 +--- tests/storage/test_memory.py | 3 +-- tests/storage/test_singlefile.py | 3 +-- tests/system/cli/conftest.py | 3 +-- tests/system/cli/test_config.py | 3 ++- tests/system/cli/test_sync.py | 4 ++-- tests/system/cli/test_utils.py | 5 +++-- tests/system/utils/test_main.py | 5 +++-- tests/unit/cli/test_fetchparams.py | 6 +++--- tests/unit/sync/test_status.py | 6 +++--- tests/unit/sync/test_sync.py | 21 ++++++++++++------- tests/unit/test_metasync.py | 9 ++++---- tests/unit/test_repair.py | 10 +++++---- tests/unit/utils/test_vobject.py | 18 +++++++++------- vdirsyncer/cli/__init__.py | 4 ++-- vdirsyncer/cli/config.py | 6 ++++-- vdirsyncer/cli/discover.py | 10 +++++---- vdirsyncer/cli/fetchparams.py | 3 ++- vdirsyncer/cli/tasks.py | 18 ++++++++++------ vdirsyncer/cli/utils.py | 19 ++++++++++------- vdirsyncer/http.py | 4 +++- vdirsyncer/repair.py | 3 ++- vdirsyncer/storage/dav.py | 14 ++++++++----- vdirsyncer/storage/etesync.py | 2 +- vdirsyncer/storage/filesystem.py | 8 +++++-- vdirsyncer/storage/google.py | 11 +++++----- vdirsyncer/storage/http.py | 12 +++++++---- vdirsyncer/storage/memory.py | 4 ++-- vdirsyncer/storage/singlefile.py | 10 ++++++--- vdirsyncer/sync/__init__.py | 11 ++++++---- vdirsyncer/sync/status.py | 2 +- vdirsyncer/utils.py | 1 - vdirsyncer/vobject.py | 6 ++++-- 52 files changed, 196 insertions(+), 156 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 21a0985..8f0b7cd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,6 +14,10 @@ repos: hooks: - id: flake8 additional_dependencies: [flake8-import-order, flake8-bugbear] + - repo: https://github.com/asottile/reorder_python_imports + rev: v2.3.0 + hooks: + - id: reorder-python-imports - repo: local hooks: - id: update-travis diff --git a/scripts/make_travisconf.py b/scripts/make_travisconf.py index 3e5882d..99b9b25 100755 --- a/scripts/make_travisconf.py +++ b/scripts/make_travisconf.py @@ -1,5 +1,4 @@ #!/usr/bin/env python - import itertools import json diff --git a/setup.py b/setup.py index 9221367..59549f1 100644 --- a/setup.py +++ b/setup.py @@ -4,9 +4,9 @@ Vdirsyncer synchronizes calendars and contacts. Please refer to https://vdirsyncer.pimutils.org/en/stable/packaging.html for how to package vdirsyncer. ''' - - -from setuptools import Command, find_packages, setup +from setuptools import Command +from setuptools import find_packages +from setuptools import setup requirements = [ diff --git a/tests/__init__.py b/tests/__init__.py index 6948552..71f69b4 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,14 +1,11 @@ ''' Test suite for vdirsyncer. ''' - import hypothesis.strategies as st +import urllib3.exceptions from vdirsyncer.vobject import normalize_item -import urllib3 -import urllib3.exceptions - urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) diff --git a/tests/conftest.py b/tests/conftest.py index 5ed34f9..b05da73 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,10 +5,10 @@ import logging import os import click_log - -from hypothesis import HealthCheck, Verbosity, settings - import pytest +from hypothesis import HealthCheck +from hypothesis import settings +from hypothesis import Verbosity @pytest.fixture(autouse=True) diff --git a/tests/storage/__init__.py b/tests/storage/__init__.py index b268972..a2e0022 100644 --- a/tests/storage/__init__.py +++ b/tests/storage/__init__.py @@ -1,21 +1,23 @@ import random -import uuid - import textwrap -from urllib.parse import quote as urlquote, unquote as urlunquote +import uuid +from urllib.parse import quote as urlquote +from urllib.parse import unquote as urlunquote import hypothesis.strategies as st +import pytest from hypothesis import given -import pytest - +from .. import assert_item_equals +from .. import EVENT_TEMPLATE +from .. import normalize_item +from .. import printable_characters_strategy +from .. import TASK_TEMPLATE +from .. import VCARD_TEMPLATE from vdirsyncer import exceptions from vdirsyncer.storage.base import normalize_meta_value from vdirsyncer.vobject import Item -from .. import EVENT_TEMPLATE, TASK_TEMPLATE, VCARD_TEMPLATE, \ - assert_item_equals, normalize_item, printable_characters_strategy - def get_server_mixin(server_name): from . import __name__ as base diff --git a/tests/storage/conftest.py b/tests/storage/conftest.py index dcb42f6..96865a6 100644 --- a/tests/storage/conftest.py +++ b/tests/storage/conftest.py @@ -1,7 +1,7 @@ -import pytest - import uuid +import pytest + @pytest.fixture def slow_create_collection(request): diff --git a/tests/storage/dav/__init__.py b/tests/storage/dav/__init__.py index 8886f73..3003df6 100644 --- a/tests/storage/dav/__init__.py +++ b/tests/storage/dav/__init__.py @@ -1,19 +1,15 @@ +import os import uuid -import os - import pytest - -import requests import requests.exceptions +from .. import get_server_mixin +from .. import StorageTests from tests import assert_item_equals - from vdirsyncer import exceptions from vdirsyncer.vobject import Item -from .. import StorageTests, get_server_mixin - dav_server = os.environ.get('DAV_SERVER', 'skip') ServerMixin = get_server_mixin(dav_server) diff --git a/tests/storage/dav/test_caldav.py b/tests/storage/dav/test_caldav.py index 1d3f2fa..37cd1f2 100644 --- a/tests/storage/dav/test_caldav.py +++ b/tests/storage/dav/test_caldav.py @@ -2,18 +2,17 @@ import datetime from textwrap import dedent import pytest - -import requests import requests.exceptions -from tests import EVENT_TEMPLATE, TASK_TEMPLATE, VCARD_TEMPLATE - +from . import dav_server +from . import DAVStorageTests +from .. import format_item +from tests import EVENT_TEMPLATE +from tests import TASK_TEMPLATE +from tests import VCARD_TEMPLATE from vdirsyncer import exceptions from vdirsyncer.storage.dav import CalDAVStorage -from . import DAVStorageTests, dav_server -from .. import format_item - class TestCalDAVStorage(DAVStorageTests): storage_class = CalDAVStorage diff --git a/tests/storage/dav/test_carddav.py b/tests/storage/dav/test_carddav.py index e15e047..a371423 100644 --- a/tests/storage/dav/test_carddav.py +++ b/tests/storage/dav/test_carddav.py @@ -1,8 +1,7 @@ import pytest -from vdirsyncer.storage.dav import CardDAVStorage - from . import DAVStorageTests +from vdirsyncer.storage.dav import CardDAVStorage class TestCardDAVStorage(DAVStorageTests): diff --git a/tests/storage/dav/test_main.py b/tests/storage/dav/test_main.py index 5766b55..ef39c46 100644 --- a/tests/storage/dav/test_main.py +++ b/tests/storage/dav/test_main.py @@ -1,6 +1,8 @@ import pytest -from vdirsyncer.storage.dav import _BAD_XML_CHARS, _merge_xml, _parse_xml +from vdirsyncer.storage.dav import _BAD_XML_CHARS +from vdirsyncer.storage.dav import _merge_xml +from vdirsyncer.storage.dav import _parse_xml def test_xml_utilities(): diff --git a/tests/storage/etesync/etesync_server/etesync_server/settings.py b/tests/storage/etesync/etesync_server/etesync_server/settings.py index 4283f1b..eccdae9 100644 --- a/tests/storage/etesync/etesync_server/etesync_server/settings.py +++ b/tests/storage/etesync/etesync_server/etesync_server/settings.py @@ -9,7 +9,6 @@ https://docs.djangoproject.com/en/1.10/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.10/ref/settings/ """ - import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) diff --git a/tests/storage/etesync/etesync_server/etesync_server/urls.py b/tests/storage/etesync/etesync_server/etesync_server/urls.py index 5b7fc61..921363d 100644 --- a/tests/storage/etesync/etesync_server/etesync_server/urls.py +++ b/tests/storage/etesync/etesync_server/etesync_server/urls.py @@ -13,11 +13,10 @@ Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ -from django.conf.urls import include, url - -from rest_framework_nested import routers - +from django.conf.urls import include +from django.conf.urls import url from journal import views +from rest_framework_nested import routers router = routers.DefaultRouter() router.register(r'journals', views.JournalViewSet) diff --git a/tests/storage/etesync/etesync_server/etesync_server/wsgi.py b/tests/storage/etesync/etesync_server/etesync_server/wsgi.py index eeb40bc..147e71e 100644 --- a/tests/storage/etesync/etesync_server/etesync_server/wsgi.py +++ b/tests/storage/etesync/etesync_server/etesync_server/wsgi.py @@ -6,7 +6,6 @@ It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ """ - import os from django.core.wsgi import get_wsgi_application diff --git a/tests/storage/etesync/test_main.py b/tests/storage/etesync/test_main.py index 2045646..b258daa 100644 --- a/tests/storage/etesync/test_main.py +++ b/tests/storage/etesync/test_main.py @@ -1,14 +1,13 @@ -import shutil import os +import shutil import sys - import pytest import requests -from vdirsyncer.storage.etesync import EtesyncContacts, EtesyncCalendars - from .. import StorageTests +from vdirsyncer.storage.etesync import EtesyncCalendars +from vdirsyncer.storage.etesync import EtesyncContacts pytestmark = pytest.mark.skipif(os.getenv('ETESYNC_TESTS', '') != 'true', diff --git a/tests/storage/servers/davical/__init__.py b/tests/storage/servers/davical/__init__.py index a402ba2..550f6e9 100644 --- a/tests/storage/servers/davical/__init__.py +++ b/tests/storage/servers/davical/__init__.py @@ -1,7 +1,8 @@ import os -import pytest import uuid +import pytest + try: caldav_args = { # Those credentials are configured through the Travis UI diff --git a/tests/storage/servers/mysteryshack/__init__.py b/tests/storage/servers/mysteryshack/__init__.py index 617c154..b238bcc 100644 --- a/tests/storage/servers/mysteryshack/__init__.py +++ b/tests/storage/servers/mysteryshack/__init__.py @@ -1,10 +1,9 @@ import os +import shutil import subprocess import time -import shutil import pytest - import requests testserver_repo = os.path.dirname(__file__) diff --git a/tests/storage/test_filesystem.py b/tests/storage/test_filesystem.py index e8a3d71..c98e86a 100644 --- a/tests/storage/test_filesystem.py +++ b/tests/storage/test_filesystem.py @@ -2,11 +2,10 @@ import subprocess import pytest +from . import StorageTests from vdirsyncer.storage.filesystem import FilesystemStorage from vdirsyncer.vobject import Item -from . import StorageTests - class TestFilesystemStorage(StorageTests): storage_class = FilesystemStorage diff --git a/tests/storage/test_http.py b/tests/storage/test_http.py index 5e63a8f..8c58c4e 100644 --- a/tests/storage/test_http.py +++ b/tests/storage/test_http.py @@ -1,11 +1,10 @@ import pytest - from requests import Response from tests import normalize_item - from vdirsyncer.exceptions import UserError -from vdirsyncer.storage.http import HttpStorage, prepare_auth +from vdirsyncer.storage.http import HttpStorage +from vdirsyncer.storage.http import prepare_auth def test_list(monkeypatch): diff --git a/tests/storage/test_http_with_singlefile.py b/tests/storage/test_http_with_singlefile.py index 6480a52..bb2b1bc 100644 --- a/tests/storage/test_http_with_singlefile.py +++ b/tests/storage/test_http_with_singlefile.py @@ -1,13 +1,11 @@ import pytest - from requests import Response import vdirsyncer.storage.http +from . import StorageTests from vdirsyncer.storage.base import Storage from vdirsyncer.storage.singlefile import SingleFileStorage -from . import StorageTests - class CombinedStorage(Storage): '''A subclass of HttpStorage to make testing easier. It supports writes via diff --git a/tests/storage/test_memory.py b/tests/storage/test_memory.py index 417db1b..82db79c 100644 --- a/tests/storage/test_memory.py +++ b/tests/storage/test_memory.py @@ -1,8 +1,7 @@ import pytest -from vdirsyncer.storage.memory import MemoryStorage - from . import StorageTests +from vdirsyncer.storage.memory import MemoryStorage class TestMemoryStorage(StorageTests): diff --git a/tests/storage/test_singlefile.py b/tests/storage/test_singlefile.py index 54ef020..b645629 100644 --- a/tests/storage/test_singlefile.py +++ b/tests/storage/test_singlefile.py @@ -1,8 +1,7 @@ import pytest -from vdirsyncer.storage.singlefile import SingleFileStorage - from . import StorageTests +from vdirsyncer.storage.singlefile import SingleFileStorage class TestSingleFileStorage(StorageTests): diff --git a/tests/system/cli/conftest.py b/tests/system/cli/conftest.py index 43e4b79..fc2225e 100644 --- a/tests/system/cli/conftest.py +++ b/tests/system/cli/conftest.py @@ -1,8 +1,7 @@ from textwrap import dedent -from click.testing import CliRunner - import pytest +from click.testing import CliRunner import vdirsyncer.cli as cli diff --git a/tests/system/cli/test_config.py b/tests/system/cli/test_config.py index 734e1ee..b88dcd5 100644 --- a/tests/system/cli/test_config.py +++ b/tests/system/cli/test_config.py @@ -3,7 +3,8 @@ from textwrap import dedent import pytest -from vdirsyncer import cli, exceptions +from vdirsyncer import cli +from vdirsyncer import exceptions from vdirsyncer.cli.config import Config diff --git a/tests/system/cli/test_sync.py b/tests/system/cli/test_sync.py index e84d798..f242376 100644 --- a/tests/system/cli/test_sync.py +++ b/tests/system/cli/test_sync.py @@ -3,9 +3,9 @@ import sys from textwrap import dedent import hypothesis.strategies as st -from hypothesis import example, given - import pytest +from hypothesis import example +from hypothesis import given def test_simple_run(tmpdir, runner): diff --git a/tests/system/cli/test_utils.py b/tests/system/cli/test_utils.py index bbf8997..23aa997 100644 --- a/tests/system/cli/test_utils.py +++ b/tests/system/cli/test_utils.py @@ -1,6 +1,7 @@ from vdirsyncer import exceptions -from vdirsyncer.cli.utils import handle_cli_error, \ - storage_instance_from_config, storage_names +from vdirsyncer.cli.utils import handle_cli_error +from vdirsyncer.cli.utils import storage_instance_from_config +from vdirsyncer.cli.utils import storage_names def test_handle_cli_error(capsys): diff --git a/tests/system/utils/test_main.py b/tests/system/utils/test_main.py index 10bfde9..9df4e86 100644 --- a/tests/system/utils/test_main.py +++ b/tests/system/utils/test_main.py @@ -1,11 +1,12 @@ -import sys import logging +import sys import click_log import pytest import requests -from vdirsyncer import http, utils +from vdirsyncer import http +from vdirsyncer import utils @pytest.fixture(autouse=True) diff --git a/tests/unit/cli/test_fetchparams.py b/tests/unit/cli/test_fetchparams.py index 9339066..664df5f 100644 --- a/tests/unit/cli/test_fetchparams.py +++ b/tests/unit/cli/test_fetchparams.py @@ -1,10 +1,10 @@ import hypothesis.strategies as st +import pytest from hypothesis import given -import pytest - from vdirsyncer import exceptions -from vdirsyncer.cli.fetchparams import STRATEGIES, expand_fetch_params +from vdirsyncer.cli.fetchparams import expand_fetch_params +from vdirsyncer.cli.fetchparams import STRATEGIES @pytest.fixture diff --git a/tests/unit/sync/test_status.py b/tests/unit/sync/test_status.py index b5fc912..6d7b549 100644 --- a/tests/unit/sync/test_status.py +++ b/tests/unit/sync/test_status.py @@ -1,7 +1,7 @@ -import pytest - -from hypothesis import assume, given import hypothesis.strategies as st +import pytest +from hypothesis import assume +from hypothesis import given from vdirsyncer.sync.status import SqliteStatus diff --git a/tests/unit/sync/test_sync.py b/tests/unit/sync/test_sync.py index 4d554c5..1a2ac71 100644 --- a/tests/unit/sync/test_sync.py +++ b/tests/unit/sync/test_sync.py @@ -1,17 +1,22 @@ from copy import deepcopy import hypothesis.strategies as st -from hypothesis import assume -from hypothesis.stateful import Bundle, RuleBasedStateMachine, rule - import pytest +from hypothesis import assume +from hypothesis.stateful import Bundle +from hypothesis.stateful import rule +from hypothesis.stateful import RuleBasedStateMachine -from tests import blow_up, uid_strategy - -from vdirsyncer.storage.memory import MemoryStorage, _random_string +from tests import blow_up +from tests import uid_strategy +from vdirsyncer.storage.memory import _random_string +from vdirsyncer.storage.memory import MemoryStorage from vdirsyncer.sync import sync as _sync -from vdirsyncer.sync.exceptions import BothReadOnly, IdentConflict, \ - PartialSync, StorageEmpty, SyncConflict +from vdirsyncer.sync.exceptions import BothReadOnly +from vdirsyncer.sync.exceptions import IdentConflict +from vdirsyncer.sync.exceptions import PartialSync +from vdirsyncer.sync.exceptions import StorageEmpty +from vdirsyncer.sync.exceptions import SyncConflict from vdirsyncer.sync.status import SqliteStatus from vdirsyncer.vobject import Item diff --git a/tests/unit/test_metasync.py b/tests/unit/test_metasync.py index ae6d94c..d342e70 100644 --- a/tests/unit/test_metasync.py +++ b/tests/unit/test_metasync.py @@ -1,12 +1,13 @@ import hypothesis.strategies as st -from hypothesis import example, given - import pytest +from hypothesis import example +from hypothesis import given from tests import blow_up - from vdirsyncer.exceptions import UserError -from vdirsyncer.metasync import MetaSyncConflict, logger, metasync +from vdirsyncer.metasync import logger +from vdirsyncer.metasync import metasync +from vdirsyncer.metasync import MetaSyncConflict from vdirsyncer.storage.base import normalize_meta_value from vdirsyncer.storage.memory import MemoryStorage diff --git a/tests/unit/test_repair.py b/tests/unit/test_repair.py index b444d0b..bac5ad5 100644 --- a/tests/unit/test_repair.py +++ b/tests/unit/test_repair.py @@ -1,10 +1,12 @@ -from hypothesis import HealthCheck, given, settings - import pytest +from hypothesis import given +from hypothesis import HealthCheck +from hypothesis import settings from tests import uid_strategy - -from vdirsyncer.repair import IrreparableItem, repair_item, repair_storage +from vdirsyncer.repair import IrreparableItem +from vdirsyncer.repair import repair_item +from vdirsyncer.repair import repair_storage from vdirsyncer.storage.memory import MemoryStorage from vdirsyncer.utils import href_safe from vdirsyncer.vobject import Item diff --git a/tests/unit/utils/test_vobject.py b/tests/unit/utils/test_vobject.py index d029ed9..44a5f8a 100644 --- a/tests/unit/utils/test_vobject.py +++ b/tests/unit/utils/test_vobject.py @@ -1,16 +1,20 @@ from textwrap import dedent import hypothesis.strategies as st -from hypothesis import assume, given -from hypothesis.stateful import Bundle, RuleBasedStateMachine, rule - import pytest - -from tests import BARE_EVENT_TEMPLATE, EVENT_TEMPLATE, \ - EVENT_WITH_TIMEZONE_TEMPLATE, VCARD_TEMPLATE, normalize_item, \ - uid_strategy +from hypothesis import assume +from hypothesis import given +from hypothesis.stateful import Bundle +from hypothesis.stateful import rule +from hypothesis.stateful import RuleBasedStateMachine import vdirsyncer.vobject as vobject +from tests import BARE_EVENT_TEMPLATE +from tests import EVENT_TEMPLATE +from tests import EVENT_WITH_TIMEZONE_TEMPLATE +from tests import normalize_item +from tests import uid_strategy +from tests import VCARD_TEMPLATE _simple_split = [ diff --git a/vdirsyncer/cli/__init__.py b/vdirsyncer/cli/__init__.py index 8f0e4e0..ff86502 100644 --- a/vdirsyncer/cli/__init__.py +++ b/vdirsyncer/cli/__init__.py @@ -3,10 +3,10 @@ import logging import sys import click - import click_log -from .. import BUGTRACKER_HOME, __version__ +from .. import __version__ +from .. import BUGTRACKER_HOME cli_logger = logging.getLogger(__name__) diff --git a/vdirsyncer/cli/config.py b/vdirsyncer/cli/config.py index 3e74420..339bde9 100644 --- a/vdirsyncer/cli/config.py +++ b/vdirsyncer/cli/config.py @@ -6,10 +6,12 @@ from itertools import chain from click_threading import get_ui_worker +from .. import exceptions +from .. import PROJECT_HOME +from ..utils import cached_property +from ..utils import expand_path from .fetchparams import expand_fetch_params from .utils import storage_class_from_config -from .. import PROJECT_HOME, exceptions -from ..utils import cached_property, expand_path GENERAL_ALL = frozenset(['status_path']) diff --git a/vdirsyncer/cli/discover.py b/vdirsyncer/cli/discover.py index b3bff73..fdc8f9d 100644 --- a/vdirsyncer/cli/discover.py +++ b/vdirsyncer/cli/discover.py @@ -3,12 +3,14 @@ import json import logging import sys -from .utils import handle_collection_not_found, handle_storage_init_error, \ - load_status, save_status, storage_class_from_config, \ - storage_instance_from_config - from .. import exceptions from ..utils import cached_property +from .utils import handle_collection_not_found +from .utils import handle_storage_init_error +from .utils import load_status +from .utils import save_status +from .utils import storage_class_from_config +from .utils import storage_instance_from_config # Increase whenever upgrade potentially breaks discovery cache and collections diff --git a/vdirsyncer/cli/fetchparams.py b/vdirsyncer/cli/fetchparams.py index 801d599..2f3e9b9 100644 --- a/vdirsyncer/cli/fetchparams.py +++ b/vdirsyncer/cli/fetchparams.py @@ -4,7 +4,8 @@ import click from . import AppContext from .. import exceptions -from ..utils import expand_path, synchronized +from ..utils import expand_path +from ..utils import synchronized SUFFIX = '.fetch' diff --git a/vdirsyncer/cli/tasks.py b/vdirsyncer/cli/tasks.py index 7cadaf2..58e14e2 100644 --- a/vdirsyncer/cli/tasks.py +++ b/vdirsyncer/cli/tasks.py @@ -1,13 +1,19 @@ import functools import json +from .. import exceptions +from .. import sync from .config import CollectionConfig -from .discover import collections_for_pair, storage_class_from_config, \ - storage_instance_from_config -from .utils import JobFailed, cli_logger, get_status_name, \ - handle_cli_error, load_status, manage_sync_status, save_status - -from .. import exceptions, sync +from .discover import collections_for_pair +from .discover import storage_class_from_config +from .discover import storage_instance_from_config +from .utils import cli_logger +from .utils import get_status_name +from .utils import handle_cli_error +from .utils import JobFailed +from .utils import load_status +from .utils import manage_sync_status +from .utils import save_status def prepare_pair(wq, pair_name, collections, config, callback, **kwargs): diff --git a/vdirsyncer/cli/utils.py b/vdirsyncer/cli/utils.py index 46e37f2..d8b420d 100644 --- a/vdirsyncer/cli/utils.py +++ b/vdirsyncer/cli/utils.py @@ -7,18 +7,21 @@ import os import queue import sys +import click +import click_threading from atomicwrites import atomic_write -import click - -import click_threading - from . import cli_logger -from .. import BUGTRACKER_HOME, DOCS_HOME, exceptions -from ..sync.exceptions import IdentConflict, PartialSync, StorageEmpty, \ - SyncConflict +from .. import BUGTRACKER_HOME +from .. import DOCS_HOME +from .. import exceptions +from ..sync.exceptions import IdentConflict +from ..sync.exceptions import PartialSync +from ..sync.exceptions import StorageEmpty +from ..sync.exceptions import SyncConflict from ..sync.status import SqliteStatus -from ..utils import expand_path, get_storage_init_args +from ..utils import expand_path +from ..utils import get_storage_init_args STATUS_PERMISSIONS = 0o600 diff --git a/vdirsyncer/http.py b/vdirsyncer/http.py index 8549216..63a5dbf 100644 --- a/vdirsyncer/http.py +++ b/vdirsyncer/http.py @@ -2,8 +2,10 @@ import logging import requests +from . import __version__ +from . import DOCS_HOME +from . import exceptions from .utils import expand_path -from . import DOCS_HOME, exceptions, __version__ logger = logging.getLogger(__name__) diff --git a/vdirsyncer/repair.py b/vdirsyncer/repair.py index 89c2c3a..3c94847 100644 --- a/vdirsyncer/repair.py +++ b/vdirsyncer/repair.py @@ -1,7 +1,8 @@ import logging from os.path import basename -from .utils import generate_href, href_safe +from .utils import generate_href +from .utils import href_safe logger = logging.getLogger(__name__) diff --git a/vdirsyncer/storage/dav.py b/vdirsyncer/storage/dav.py index 4481e15..07d164f 100644 --- a/vdirsyncer/storage/dav.py +++ b/vdirsyncer/storage/dav.py @@ -2,17 +2,21 @@ import datetime import logging import urllib.parse as urlparse import xml.etree.ElementTree as etree - from inspect import getfullargspec import requests from requests.exceptions import HTTPError -from .base import Storage, normalize_meta_value -from .. import exceptions, http, utils -from ..http import USERAGENT, prepare_auth, \ - prepare_client_cert, prepare_verify +from .. import exceptions +from .. import http +from .. import utils +from ..http import prepare_auth +from ..http import prepare_client_cert +from ..http import prepare_verify +from ..http import USERAGENT from ..vobject import Item +from .base import normalize_meta_value +from .base import Storage dav_logger = logging.getLogger(__name__) diff --git a/vdirsyncer/storage/etesync.py b/vdirsyncer/storage/etesync.py index e351d61..88bf07c 100644 --- a/vdirsyncer/storage/etesync.py +++ b/vdirsyncer/storage/etesync.py @@ -1,8 +1,8 @@ +import binascii import contextlib import functools import logging import os -import binascii import atomicwrites import click diff --git a/vdirsyncer/storage/filesystem.py b/vdirsyncer/storage/filesystem.py index 8859bbc..b398119 100644 --- a/vdirsyncer/storage/filesystem.py +++ b/vdirsyncer/storage/filesystem.py @@ -5,10 +5,14 @@ import subprocess from atomicwrites import atomic_write -from .base import Storage, normalize_meta_value from .. import exceptions -from ..utils import checkdir, expand_path, generate_href, get_etag_from_file +from ..utils import checkdir +from ..utils import expand_path +from ..utils import generate_href +from ..utils import get_etag_from_file from ..vobject import Item +from .base import normalize_meta_value +from .base import Storage logger = logging.getLogger(__name__) diff --git a/vdirsyncer/storage/google.py b/vdirsyncer/storage/google.py index 1702f01..675c273 100644 --- a/vdirsyncer/storage/google.py +++ b/vdirsyncer/storage/google.py @@ -3,15 +3,16 @@ import logging import os import urllib.parse as urlparse -from atomicwrites import atomic_write - import click - +from atomicwrites import atomic_write from click_threading import get_ui_worker -from . import base, dav +from . import base +from . import dav from .. import exceptions -from ..utils import checkdir, expand_path, open_graphical_browser +from ..utils import checkdir +from ..utils import expand_path +from ..utils import open_graphical_browser logger = logging.getLogger(__name__) diff --git a/vdirsyncer/storage/http.py b/vdirsyncer/storage/http.py index b9f12e9..e3ca984 100644 --- a/vdirsyncer/storage/http.py +++ b/vdirsyncer/storage/http.py @@ -1,10 +1,14 @@ import urllib.parse as urlparse -from .base import Storage from .. import exceptions -from ..http import USERAGENT, prepare_auth, \ - prepare_client_cert, prepare_verify, request -from ..vobject import Item, split_collection +from ..http import prepare_auth +from ..http import prepare_client_cert +from ..http import prepare_verify +from ..http import request +from ..http import USERAGENT +from ..vobject import Item +from ..vobject import split_collection +from .base import Storage class HttpStorage(Storage): diff --git a/vdirsyncer/storage/memory.py b/vdirsyncer/storage/memory.py index 99e533b..e953691 100644 --- a/vdirsyncer/storage/memory.py +++ b/vdirsyncer/storage/memory.py @@ -1,8 +1,8 @@ import random -from .base import Storage, normalize_meta_value - from .. import exceptions +from .base import normalize_meta_value +from .base import Storage def _random_string(): diff --git a/vdirsyncer/storage/singlefile.py b/vdirsyncer/storage/singlefile.py index 5a56aef..829204c 100644 --- a/vdirsyncer/storage/singlefile.py +++ b/vdirsyncer/storage/singlefile.py @@ -7,10 +7,14 @@ import os from atomicwrites import atomic_write -from .base import Storage from .. import exceptions -from ..utils import checkfile, expand_path, get_etag_from_file -from ..vobject import Item, join_collection, split_collection +from ..utils import checkfile +from ..utils import expand_path +from ..utils import get_etag_from_file +from ..vobject import Item +from ..vobject import join_collection +from ..vobject import split_collection +from .base import Storage logger = logging.getLogger(__name__) diff --git a/vdirsyncer/sync/__init__.py b/vdirsyncer/sync/__init__.py index bdb945d..2119063 100644 --- a/vdirsyncer/sync/__init__.py +++ b/vdirsyncer/sync/__init__.py @@ -15,10 +15,13 @@ import logging from ..exceptions import UserError from ..utils import uniq - -from .status import SubStatus, ItemMetadata -from .exceptions import BothReadOnly, IdentAlreadyExists, PartialSync, \ - StorageEmpty, SyncConflict +from .exceptions import BothReadOnly +from .exceptions import IdentAlreadyExists +from .exceptions import PartialSync +from .exceptions import StorageEmpty +from .exceptions import SyncConflict +from .status import ItemMetadata +from .status import SubStatus sync_logger = logging.getLogger(__name__) diff --git a/vdirsyncer/sync/status.py b/vdirsyncer/sync/status.py index 2544680..48b5634 100644 --- a/vdirsyncer/sync/status.py +++ b/vdirsyncer/sync/status.py @@ -1,7 +1,7 @@ import abc import contextlib -import sys import sqlite3 +import sys from .exceptions import IdentAlreadyExists diff --git a/vdirsyncer/utils.py b/vdirsyncer/utils.py index 2737cbe..8730519 100644 --- a/vdirsyncer/utils.py +++ b/vdirsyncer/utils.py @@ -2,7 +2,6 @@ import functools import os import sys import uuid - from inspect import getfullargspec from . import exceptions diff --git a/vdirsyncer/vobject.py b/vdirsyncer/vobject.py index 33c2d3d..92e46d2 100644 --- a/vdirsyncer/vobject.py +++ b/vdirsyncer/vobject.py @@ -1,7 +1,9 @@ import hashlib -from itertools import chain, tee +from itertools import chain +from itertools import tee -from .utils import cached_property, uniq +from .utils import cached_property +from .utils import uniq IGNORE_PROPS = (