From b50f9def00b80c8a1c6170532f4d2209052de488 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Sun, 29 Oct 2023 16:04:23 +0100 Subject: [PATCH] Ensure type annotations are backwards compatible Related: https://github.com/pimutils/todoman/issues/544 --- .../conflict_resolution/resolve_interactively.py | 2 ++ docs/conf.py | 2 ++ pyproject.toml | 1 + setup.py | 2 ++ tests/__init__.py | 2 ++ tests/conftest.py | 2 ++ tests/storage/__init__.py | 2 ++ tests/storage/conftest.py | 5 +++-- tests/storage/dav/__init__.py | 2 ++ tests/storage/dav/test_caldav.py | 2 ++ tests/storage/dav/test_carddav.py | 2 ++ tests/storage/dav/test_main.py | 2 ++ tests/storage/servers/baikal/__init__.py | 2 ++ tests/storage/servers/davical/__init__.py | 2 ++ tests/storage/servers/fastmail/__init__.py | 2 ++ tests/storage/servers/icloud/__init__.py | 2 ++ tests/storage/servers/radicale/__init__.py | 2 ++ tests/storage/servers/skip/__init__.py | 2 ++ tests/storage/servers/xandikos/__init__.py | 2 ++ tests/storage/test_filesystem.py | 2 ++ tests/storage/test_http.py | 2 ++ tests/storage/test_http_with_singlefile.py | 2 ++ tests/storage/test_memory.py | 2 ++ tests/storage/test_singlefile.py | 2 ++ tests/system/cli/conftest.py | 2 ++ tests/system/cli/test_config.py | 2 ++ tests/system/cli/test_discover.py | 5 +++-- tests/system/cli/test_fetchparams.py | 2 ++ tests/system/cli/test_repair.py | 2 ++ tests/system/cli/test_sync.py | 2 ++ tests/system/cli/test_utils.py | 2 ++ tests/system/conftest.py | 2 ++ tests/system/utils/test_main.py | 2 ++ tests/unit/cli/test_config.py | 2 ++ tests/unit/cli/test_discover.py | 2 ++ tests/unit/cli/test_fetchparams.py | 2 ++ tests/unit/sync/test_status.py | 2 ++ tests/unit/sync/test_sync.py | 2 ++ tests/unit/test_exceptions.py | 2 ++ tests/unit/test_metasync.py | 2 ++ tests/unit/test_repair.py | 2 ++ tests/unit/utils/test_vobject.py | 2 ++ vdirsyncer/__init__.py | 2 +- vdirsyncer/__main__.py | 2 ++ vdirsyncer/cli/__init__.py | 2 ++ vdirsyncer/cli/discover.py | 2 ++ vdirsyncer/cli/fetchparams.py | 2 ++ vdirsyncer/cli/tasks.py | 2 ++ vdirsyncer/exceptions.py | 1 + vdirsyncer/http.py | 2 ++ vdirsyncer/metasync.py | 2 ++ vdirsyncer/repair.py | 2 ++ vdirsyncer/storage/base.py | 14 +++++++------- vdirsyncer/storage/dav.py | 12 ++++++------ vdirsyncer/storage/filesystem.py | 2 ++ vdirsyncer/storage/google.py | 2 ++ vdirsyncer/storage/google_helpers.py | 7 +++---- vdirsyncer/storage/http.py | 4 +++- vdirsyncer/storage/memory.py | 2 ++ vdirsyncer/storage/singlefile.py | 2 ++ vdirsyncer/sync/__init__.py | 2 ++ vdirsyncer/sync/exceptions.py | 2 ++ vdirsyncer/sync/status.py | 2 ++ vdirsyncer/utils.py | 2 ++ vdirsyncer/vobject.py | 2 ++ 65 files changed, 140 insertions(+), 23 deletions(-) diff --git a/contrib/conflict_resolution/resolve_interactively.py b/contrib/conflict_resolution/resolve_interactively.py index 6da9ab7..d676496 100755 --- a/contrib/conflict_resolution/resolve_interactively.py +++ b/contrib/conflict_resolution/resolve_interactively.py @@ -16,6 +16,8 @@ SPDX-License-Identifier: BSD-3-Clause SPDX-FileCopyrightText: 2021 Intevation GmbH Author: """ +from __future__ import annotations + import re import subprocess import sys diff --git a/docs/conf.py b/docs/conf.py index 533ddec..807997b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import datetime import os diff --git a/pyproject.toml b/pyproject.toml index 294438a..6d7b031 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ target-version = "py37" [tool.ruff.isort] force-single-line = true +required-imports = ["from __future__ import annotations"] [tool.pytest.ini_options] addopts = """ diff --git a/setup.py b/setup.py index 0e8ba30..279df5d 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,8 @@ Vdirsyncer synchronizes calendars and contacts. Please refer to https://vdirsyncer.pimutils.org/en/stable/packaging.html for how to package vdirsyncer. """ +from __future__ import annotations + from setuptools import Command from setuptools import find_packages from setuptools import setup diff --git a/tests/__init__.py b/tests/__init__.py index c8b4c2c..72007f6 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,6 +1,8 @@ """ Test suite for vdirsyncer. """ +from __future__ import annotations + import hypothesis.strategies as st import urllib3.exceptions diff --git a/tests/conftest.py b/tests/conftest.py index 2cc19be..3eb2b62 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,8 @@ """ General-purpose fixtures for vdirsyncer's testsuite. """ +from __future__ import annotations + import logging import os diff --git a/tests/storage/__init__.py b/tests/storage/__init__.py index 51a66a0..0f11930 100644 --- a/tests/storage/__init__.py +++ b/tests/storage/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import random import textwrap import uuid diff --git a/tests/storage/conftest.py b/tests/storage/conftest.py index 76fe8d3..5b7485f 100644 --- a/tests/storage/conftest.py +++ b/tests/storage/conftest.py @@ -1,9 +1,10 @@ +from __future__ import annotations + import asyncio import contextlib import subprocess import time import uuid -from typing import Type import aiostream import pytest @@ -90,7 +91,7 @@ async def slow_create_collection(request, aio_connector): # storage limits. to_delete = [] - async def inner(cls: Type, args: dict, collection_name: str) -> dict: + async def inner(cls: type, args: dict, collection_name: str) -> dict: """Create a collection Returns args necessary to create a Storage instance pointing to it. diff --git a/tests/storage/dav/__init__.py b/tests/storage/dav/__init__.py index b97b2cc..912530e 100644 --- a/tests/storage/dav/__init__.py +++ b/tests/storage/dav/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import uuid diff --git a/tests/storage/dav/test_caldav.py b/tests/storage/dav/test_caldav.py index e68d09b..656c7b4 100644 --- a/tests/storage/dav/test_caldav.py +++ b/tests/storage/dav/test_caldav.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import datetime from textwrap import dedent diff --git a/tests/storage/dav/test_carddav.py b/tests/storage/dav/test_carddav.py index 5a42399..e9c6c1f 100644 --- a/tests/storage/dav/test_carddav.py +++ b/tests/storage/dav/test_carddav.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from vdirsyncer.storage.dav import CardDAVStorage diff --git a/tests/storage/dav/test_main.py b/tests/storage/dav/test_main.py index 08d7126..4fa875d 100644 --- a/tests/storage/dav/test_main.py +++ b/tests/storage/dav/test_main.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from vdirsyncer.storage.dav import _BAD_XML_CHARS diff --git a/tests/storage/servers/baikal/__init__.py b/tests/storage/servers/baikal/__init__.py index ad27b39..fa5cd14 100644 --- a/tests/storage/servers/baikal/__init__.py +++ b/tests/storage/servers/baikal/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest diff --git a/tests/storage/servers/davical/__init__.py b/tests/storage/servers/davical/__init__.py index abe0669..b3af413 100644 --- a/tests/storage/servers/davical/__init__.py +++ b/tests/storage/servers/davical/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import uuid diff --git a/tests/storage/servers/fastmail/__init__.py b/tests/storage/servers/fastmail/__init__.py index 548aa49..6b6608f 100644 --- a/tests/storage/servers/fastmail/__init__.py +++ b/tests/storage/servers/fastmail/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import pytest diff --git a/tests/storage/servers/icloud/__init__.py b/tests/storage/servers/icloud/__init__.py index 096702c..eb6af67 100644 --- a/tests/storage/servers/icloud/__init__.py +++ b/tests/storage/servers/icloud/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import pytest diff --git a/tests/storage/servers/radicale/__init__.py b/tests/storage/servers/radicale/__init__.py index f59cc81..fc302b3 100644 --- a/tests/storage/servers/radicale/__init__.py +++ b/tests/storage/servers/radicale/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest diff --git a/tests/storage/servers/skip/__init__.py b/tests/storage/servers/skip/__init__.py index db17b0a..f8cc61c 100644 --- a/tests/storage/servers/skip/__init__.py +++ b/tests/storage/servers/skip/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest diff --git a/tests/storage/servers/xandikos/__init__.py b/tests/storage/servers/xandikos/__init__.py index 36b4eda..f8936dc 100644 --- a/tests/storage/servers/xandikos/__init__.py +++ b/tests/storage/servers/xandikos/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest diff --git a/tests/storage/test_filesystem.py b/tests/storage/test_filesystem.py index 9ae6ec0..ca7e9d3 100644 --- a/tests/storage/test_filesystem.py +++ b/tests/storage/test_filesystem.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import subprocess import aiostream diff --git a/tests/storage/test_http.py b/tests/storage/test_http.py index 0e0247f..2e92d13 100644 --- a/tests/storage/test_http.py +++ b/tests/storage/test_http.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from aiohttp import BasicAuth from aioresponses import CallbackResult diff --git a/tests/storage/test_http_with_singlefile.py b/tests/storage/test_http_with_singlefile.py index 3a157ca..5d29eae 100644 --- a/tests/storage/test_http_with_singlefile.py +++ b/tests/storage/test_http_with_singlefile.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import aiostream import pytest from aioresponses import CallbackResult diff --git a/tests/storage/test_memory.py b/tests/storage/test_memory.py index d180897..a3a0143 100644 --- a/tests/storage/test_memory.py +++ b/tests/storage/test_memory.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from vdirsyncer.storage.memory import MemoryStorage diff --git a/tests/storage/test_singlefile.py b/tests/storage/test_singlefile.py index 9e838aa..96cccda 100644 --- a/tests/storage/test_singlefile.py +++ b/tests/storage/test_singlefile.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from vdirsyncer.storage.singlefile import SingleFileStorage diff --git a/tests/system/cli/conftest.py b/tests/system/cli/conftest.py index 85e07ca..c9e206c 100644 --- a/tests/system/cli/conftest.py +++ b/tests/system/cli/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent import pytest diff --git a/tests/system/cli/test_config.py b/tests/system/cli/test_config.py index 3e037c9..f701bb8 100644 --- a/tests/system/cli/test_config.py +++ b/tests/system/cli/test_config.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io from textwrap import dedent diff --git a/tests/system/cli/test_discover.py b/tests/system/cli/test_discover.py index b2f3235..a50b56a 100644 --- a/tests/system/cli/test_discover.py +++ b/tests/system/cli/test_discover.py @@ -1,6 +1,7 @@ +from __future__ import annotations + import json from textwrap import dedent -from typing import List import pytest @@ -210,7 +211,7 @@ def test_collection_required(a_requires, b_requires, tmpdir, runner, monkeypatch async def get(self, href: str): raise NotImplementedError - async def list(self) -> List[tuple]: + async def list(self) -> list[tuple]: raise NotImplementedError from vdirsyncer.cli.utils import storage_names diff --git a/tests/system/cli/test_fetchparams.py b/tests/system/cli/test_fetchparams.py index fdc8d91..af257b0 100644 --- a/tests/system/cli/test_fetchparams.py +++ b/tests/system/cli/test_fetchparams.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent diff --git a/tests/system/cli/test_repair.py b/tests/system/cli/test_repair.py index 7eed4ad..26e2edb 100644 --- a/tests/system/cli/test_repair.py +++ b/tests/system/cli/test_repair.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent import pytest diff --git a/tests/system/cli/test_sync.py b/tests/system/cli/test_sync.py index 4fd1cfd..ee2afbc 100644 --- a/tests/system/cli/test_sync.py +++ b/tests/system/cli/test_sync.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json import sys from textwrap import dedent diff --git a/tests/system/cli/test_utils.py b/tests/system/cli/test_utils.py index fe6722e..56e561b 100644 --- a/tests/system/cli/test_utils.py +++ b/tests/system/cli/test_utils.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from vdirsyncer import exceptions diff --git a/tests/system/conftest.py b/tests/system/conftest.py index 59271e5..c4dc9b3 100644 --- a/tests/system/conftest.py +++ b/tests/system/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import ssl import pytest diff --git a/tests/system/utils/test_main.py b/tests/system/utils/test_main.py index 4d179e7..9177daf 100644 --- a/tests/system/utils/test_main.py +++ b/tests/system/utils/test_main.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging import aiohttp diff --git a/tests/unit/cli/test_config.py b/tests/unit/cli/test_config.py index 19edd5e..245fcb6 100644 --- a/tests/unit/cli/test_config.py +++ b/tests/unit/cli/test_config.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from vdirsyncer.cli.config import _resolve_conflict_via_command diff --git a/tests/unit/cli/test_discover.py b/tests/unit/cli/test_discover.py index 4c24a38..fef646e 100644 --- a/tests/unit/cli/test_discover.py +++ b/tests/unit/cli/test_discover.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import aiostream import pytest diff --git a/tests/unit/cli/test_fetchparams.py b/tests/unit/cli/test_fetchparams.py index d3d7229..677e86d 100644 --- a/tests/unit/cli/test_fetchparams.py +++ b/tests/unit/cli/test_fetchparams.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from contextlib import contextmanager from unittest.mock import patch diff --git a/tests/unit/sync/test_status.py b/tests/unit/sync/test_status.py index 7255e2c..a88d572 100644 --- a/tests/unit/sync/test_status.py +++ b/tests/unit/sync/test_status.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import hypothesis.strategies as st from hypothesis import assume from hypothesis import given diff --git a/tests/unit/sync/test_sync.py b/tests/unit/sync/test_sync.py index 7720d30..c3ea627 100644 --- a/tests/unit/sync/test_sync.py +++ b/tests/unit/sync/test_sync.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import asyncio from copy import deepcopy diff --git a/tests/unit/test_exceptions.py b/tests/unit/test_exceptions.py index aba6e65..2f1f235 100644 --- a/tests/unit/test_exceptions.py +++ b/tests/unit/test_exceptions.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from vdirsyncer import exceptions diff --git a/tests/unit/test_metasync.py b/tests/unit/test_metasync.py index e685580..e099db1 100644 --- a/tests/unit/test_metasync.py +++ b/tests/unit/test_metasync.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import hypothesis.strategies as st import pytest import pytest_asyncio diff --git a/tests/unit/test_repair.py b/tests/unit/test_repair.py index 3a153bc..3a4b3cb 100644 --- a/tests/unit/test_repair.py +++ b/tests/unit/test_repair.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import aiostream import pytest from hypothesis import HealthCheck diff --git a/tests/unit/utils/test_vobject.py b/tests/unit/utils/test_vobject.py index abd1e05..3745411 100644 --- a/tests/unit/utils/test_vobject.py +++ b/tests/unit/utils/test_vobject.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent import hypothesis.strategies as st diff --git a/vdirsyncer/__init__.py b/vdirsyncer/__init__.py index f982dbc..9d5b310 100644 --- a/vdirsyncer/__init__.py +++ b/vdirsyncer/__init__.py @@ -1,7 +1,7 @@ """ Vdirsyncer synchronizes calendars and contacts. """ - +from __future__ import annotations PROJECT_HOME = "https://github.com/pimutils/vdirsyncer" BUGTRACKER_HOME = PROJECT_HOME + "/issues" diff --git a/vdirsyncer/__main__.py b/vdirsyncer/__main__.py index e867465..edf332d 100644 --- a/vdirsyncer/__main__.py +++ b/vdirsyncer/__main__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + if __name__ == "__main__": from vdirsyncer.cli import app diff --git a/vdirsyncer/cli/__init__.py b/vdirsyncer/cli/__init__.py index ff42cdc..6b993d0 100644 --- a/vdirsyncer/cli/__init__.py +++ b/vdirsyncer/cli/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import asyncio import functools import json diff --git a/vdirsyncer/cli/discover.py b/vdirsyncer/cli/discover.py index c3870ea..247306e 100644 --- a/vdirsyncer/cli/discover.py +++ b/vdirsyncer/cli/discover.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import asyncio import hashlib import json diff --git a/vdirsyncer/cli/fetchparams.py b/vdirsyncer/cli/fetchparams.py index f4d56fc..87a483a 100644 --- a/vdirsyncer/cli/fetchparams.py +++ b/vdirsyncer/cli/fetchparams.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging import click diff --git a/vdirsyncer/cli/tasks.py b/vdirsyncer/cli/tasks.py index 0207cb1..6e8f5ba 100644 --- a/vdirsyncer/cli/tasks.py +++ b/vdirsyncer/cli/tasks.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json import aiohttp diff --git a/vdirsyncer/exceptions.py b/vdirsyncer/exceptions.py index 53a119c..5bab293 100644 --- a/vdirsyncer/exceptions.py +++ b/vdirsyncer/exceptions.py @@ -2,6 +2,7 @@ Contains exception classes used by vdirsyncer. Not all exceptions are here, only the most commonly used ones. """ +from __future__ import annotations class Error(Exception): diff --git a/vdirsyncer/http.py b/vdirsyncer/http.py index f56afa9..69ad845 100644 --- a/vdirsyncer/http.py +++ b/vdirsyncer/http.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging from ssl import create_default_context diff --git a/vdirsyncer/metasync.py b/vdirsyncer/metasync.py index cf5a282..1d34dd2 100644 --- a/vdirsyncer/metasync.py +++ b/vdirsyncer/metasync.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging from . import exceptions diff --git a/vdirsyncer/repair.py b/vdirsyncer/repair.py index cc9609e..7a1116e 100644 --- a/vdirsyncer/repair.py +++ b/vdirsyncer/repair.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging from os.path import basename diff --git a/vdirsyncer/storage/base.py b/vdirsyncer/storage/base.py index ee9acdf..bd1fdc6 100644 --- a/vdirsyncer/storage/base.py +++ b/vdirsyncer/storage/base.py @@ -1,10 +1,10 @@ +from __future__ import annotations + import contextlib import functools from abc import ABCMeta from abc import abstractmethod from typing import Iterable -from typing import List -from typing import Optional from vdirsyncer.vobject import Item @@ -73,7 +73,7 @@ class Storage(metaclass=StorageMeta): read_only = False # The attribute values to show in the representation of the storage. - _repr_attributes: List[str] = [] + _repr_attributes: list[str] = [] def __init__(self, instance_name=None, read_only=None, collection=None): if read_only is None: @@ -132,7 +132,7 @@ class Storage(metaclass=StorageMeta): ) @abstractmethod - async def list(self) -> List[tuple]: + async def list(self) -> list[tuple]: """ :returns: list of (href, etag) """ @@ -227,7 +227,7 @@ class Storage(metaclass=StorageMeta): """ yield - async def get_meta(self, key: str) -> Optional[str]: + async def get_meta(self, key: str) -> str | None: """Get metadata value for collection/storage. See the vdir specification for the keys that *have* to be accepted. @@ -237,7 +237,7 @@ class Storage(metaclass=StorageMeta): """ raise NotImplementedError("This storage does not support metadata.") - async def set_meta(self, key: str, value: Optional[str]): + async def set_meta(self, key: str, value: str | None): """Set metadata value for collection/storage. :param key: The metadata key. @@ -246,7 +246,7 @@ class Storage(metaclass=StorageMeta): raise NotImplementedError("This storage does not support metadata.") -def normalize_meta_value(value) -> Optional[str]: +def normalize_meta_value(value) -> str | None: # `None` is returned by iCloud for empty properties. if value is None or value == "None": return None diff --git a/vdirsyncer/storage/dav.py b/vdirsyncer/storage/dav.py index 25f5d12..697ebf0 100644 --- a/vdirsyncer/storage/dav.py +++ b/vdirsyncer/storage/dav.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import datetime import logging import urllib.parse as urlparse @@ -5,8 +7,6 @@ import xml.etree.ElementTree as etree from abc import abstractmethod from inspect import getfullargspec from inspect import signature -from typing import Optional -from typing import Type import aiohttp import aiostream @@ -127,7 +127,7 @@ class Discover: @property @abstractmethod - def _resourcetype(self) -> Optional[str]: + def _resourcetype(self) -> str | None: pass @property @@ -339,7 +339,7 @@ class CalDiscover(Discover): class CardDiscover(Discover): _namespace = "urn:ietf:params:xml:ns:carddav" - _resourcetype: Optional[str] = "{%s}addressbook" % _namespace + _resourcetype: str | None = "{%s}addressbook" % _namespace _homeset_xml = b""" @@ -448,7 +448,7 @@ class DAVStorage(Storage): @property @abstractmethod - def discovery_class(self) -> Type[Discover]: + def discovery_class(self) -> type[Discover]: """Discover subclass to use.""" # The DAVSession class to use @@ -681,7 +681,7 @@ class DAVStorage(Storage): for href, etag, _prop in rv: yield href, etag - async def get_meta(self, key) -> Optional[str]: + async def get_meta(self, key) -> str | None: try: tagname, namespace = self._property_table[key] except KeyError: diff --git a/vdirsyncer/storage/filesystem.py b/vdirsyncer/storage/filesystem.py index 4992bc1..0be62b4 100644 --- a/vdirsyncer/storage/filesystem.py +++ b/vdirsyncer/storage/filesystem.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import errno import logging import os diff --git a/vdirsyncer/storage/google.py b/vdirsyncer/storage/google.py index 4933deb..93b7848 100644 --- a/vdirsyncer/storage/google.py +++ b/vdirsyncer/storage/google.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json import logging import os diff --git a/vdirsyncer/storage/google_helpers.py b/vdirsyncer/storage/google_helpers.py index d85e730..ac333f4 100644 --- a/vdirsyncer/storage/google_helpers.py +++ b/vdirsyncer/storage/google_helpers.py @@ -2,15 +2,14 @@ # # Based on: # https://github.com/googleapis/google-auth-library-python-oauthlib/blob/1fb16be1bad9050ee29293541be44e41e82defd7/google_auth_oauthlib/flow.py#L513 +from __future__ import annotations import logging import wsgiref.simple_server import wsgiref.util from typing import Any from typing import Callable -from typing import Dict from typing import Iterable -from typing import Optional logger = logging.getLogger(__name__) @@ -29,7 +28,7 @@ class _RedirectWSGIApp: Stores the request URI and displays the given success message. """ - last_request_uri: Optional[str] + last_request_uri: str | None def __init__(self, success_message: str): """ @@ -41,7 +40,7 @@ class _RedirectWSGIApp: def __call__( self, - environ: Dict[str, Any], + environ: dict[str, Any], start_response: Callable[[str, list], None], ) -> Iterable[bytes]: """WSGI Callable. diff --git a/vdirsyncer/storage/http.py b/vdirsyncer/storage/http.py index 177e769..41d94e8 100644 --- a/vdirsyncer/storage/http.py +++ b/vdirsyncer/storage/http.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import urllib.parse as urlparse import aiohttp @@ -34,7 +36,7 @@ class HttpStorage(Storage): auth_cert=None, *, connector, - **kwargs + **kwargs, ) -> None: super().__init__(**kwargs) diff --git a/vdirsyncer/storage/memory.py b/vdirsyncer/storage/memory.py index 9e60bcc..d872312 100644 --- a/vdirsyncer/storage/memory.py +++ b/vdirsyncer/storage/memory.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import random from .. import exceptions diff --git a/vdirsyncer/storage/singlefile.py b/vdirsyncer/storage/singlefile.py index b443f5a..9827632 100644 --- a/vdirsyncer/storage/singlefile.py +++ b/vdirsyncer/storage/singlefile.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import collections import contextlib import functools diff --git a/vdirsyncer/sync/__init__.py b/vdirsyncer/sync/__init__.py index d596488..c84f977 100644 --- a/vdirsyncer/sync/__init__.py +++ b/vdirsyncer/sync/__init__.py @@ -9,6 +9,8 @@ Yang: http://blog.ezyang.com/2012/08/how-offlineimap-works/ Some modifications to it are explained in https://unterwaditzer.net/2016/sync-algorithm.html """ +from __future__ import annotations + import contextlib import itertools import logging diff --git a/vdirsyncer/sync/exceptions.py b/vdirsyncer/sync/exceptions.py index 863d5a4..9fa5bf2 100644 --- a/vdirsyncer/sync/exceptions.py +++ b/vdirsyncer/sync/exceptions.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from .. import exceptions diff --git a/vdirsyncer/sync/status.py b/vdirsyncer/sync/status.py index dc3ba84..856f889 100644 --- a/vdirsyncer/sync/status.py +++ b/vdirsyncer/sync/status.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import abc import contextlib import sqlite3 diff --git a/vdirsyncer/utils.py b/vdirsyncer/utils.py index b4ae102..2e0fd9c 100644 --- a/vdirsyncer/utils.py +++ b/vdirsyncer/utils.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import functools import os import sys diff --git a/vdirsyncer/vobject.py b/vdirsyncer/vobject.py index 2f18f69..d53c75b 100644 --- a/vdirsyncer/vobject.py +++ b/vdirsyncer/vobject.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import hashlib from itertools import chain from itertools import tee