diff --git a/src/_zkapauthorizer/_storage_server.py b/src/_zkapauthorizer/_storage_server.py index 50e19201b64c04325d5741f36adcc0598f0e2862..7d3b0050a9e309697d0ee07c7defc587adf74a09 100644 --- a/src/_zkapauthorizer/_storage_server.py +++ b/src/_zkapauthorizer/_storage_server.py @@ -30,11 +30,14 @@ from os import listdir, stat from os.path import join from struct import calcsize, unpack +try: + from typing import Generator, Iterable, Tuple, List, Dict, Optional +except ImportError: + pass + import attr from allmydata.interfaces import RIStorageServer from allmydata.storage.common import storage_index_to_dir -from allmydata.storage.immutable import ShareFile -from allmydata.storage.mutable import MutableShareFile from allmydata.storage.shares import get_share_file from allmydata.util.base32 import b2a from attr.validators import instance_of, provides diff --git a/src/_zkapauthorizer/lease_maintenance.py b/src/_zkapauthorizer/lease_maintenance.py index 9fe3186224f334446e83e5ac829e47942d78a2e3..2920a4bf56478c214089049ce736130f048e0386 100644 --- a/src/_zkapauthorizer/lease_maintenance.py +++ b/src/_zkapauthorizer/lease_maintenance.py @@ -21,6 +21,11 @@ from datetime import datetime, timedelta from errno import ENOENT from functools import partial +try: + from typing import Iterable +except ImportError: + pass + import attr from allmydata.interfaces import IDirectoryNode, IFilesystemNode from allmydata.util.hashutil import ( @@ -37,6 +42,7 @@ from zope.interface import implementer from .controller import bracket from .model import ILeaseMaintenanceObserver +from .foolscap import ShareStat SERVICE_NAME = u"lease maintenance service" diff --git a/src/_zkapauthorizer/tests/test_lease_maintenance.py b/src/_zkapauthorizer/tests/test_lease_maintenance.py index 87345284ccf38f17272596dd71e1e6bf916bff6e..a6e168060072783f6358d5f89c3f057c7c6ee9fa 100644 --- a/src/_zkapauthorizer/tests/test_lease_maintenance.py +++ b/src/_zkapauthorizer/tests/test_lease_maintenance.py @@ -20,6 +20,11 @@ from __future__ import absolute_import, unicode_literals from datetime import datetime, timedelta +try: + from typing import Dict, List +except ImportError: + pass + import attr from allmydata.client import SecretHolder from allmydata.interfaces import IServer, IStorageBroker @@ -37,7 +42,6 @@ from hypothesis.strategies import ( lists, randoms, sets, - tuples, ) from testtools import TestCase from testtools.matchers import ( @@ -51,7 +55,7 @@ from testtools.matchers import ( ) from testtools.twistedsupport import succeeded from twisted.application.service import IService -from twisted.internet.defer import maybeDeferred, succeed +from twisted.internet.defer import Deferred, maybeDeferred, succeed from twisted.internet.task import Clock from twisted.python.filepath import FilePath from zope.interface import implementer @@ -460,7 +464,6 @@ def lists_of_buckets(): min_size=count, max_size=count, ) - expiration_strategy = lists return builds( zip, si_strategy, diff --git a/src/_zkapauthorizer/tests/test_plugin.py b/src/_zkapauthorizer/tests/test_plugin.py index f5fd113168f118c415ee9124f707698c33a212a9..48e0eaa84ab2c46b864ba42e758b7fad49c3bf21 100644 --- a/src/_zkapauthorizer/tests/test_plugin.py +++ b/src/_zkapauthorizer/tests/test_plugin.py @@ -38,8 +38,7 @@ from foolscap.ipb import IReferenceable, IRemotelyCallable from foolscap.referenceable import LocalReferenceable from hypothesis import given, settings from hypothesis.strategies import datetimes, just, sampled_from, timedeltas -from isodate import duration_isoformat -from prometheus_client import CollectorRegistry, Gauge +from prometheus_client import Gauge from StringIO import StringIO from testtools import TestCase from testtools.content import text_content @@ -278,7 +277,7 @@ class ServerPluginTests(TestCase): metrics_path = self.useFixture(TempDir()).join(u"metrics") configuration = { u"prometheus-metrics-path": metrics_path, - u"prometheus-metrics-interval": duration_isoformat(metrics_interval), + u"prometheus-metrics-interval": str(metrics_interval.total_seconds()), u"ristretto-issuer-root-url": "foo", u"ristretto-signing-key-path": SIGNING_KEY_PATH.path, } diff --git a/src/_zkapauthorizer/tests/test_storage_server.py b/src/_zkapauthorizer/tests/test_storage_server.py index e20da2a679ebec92ee88e0c91a77f4d42a98418b..6d79127512e752afbf4922cb0a95e4355e556a7a 100644 --- a/src/_zkapauthorizer/tests/test_storage_server.py +++ b/src/_zkapauthorizer/tests/test_storage_server.py @@ -25,9 +25,9 @@ from prometheus_client import CollectorRegistry, Histogram from challenge_bypass_ristretto import RandomToken, random_signing_key from foolscap.referenceable import LocalReferenceable from hypothesis import given, note -from hypothesis.strategies import integers, just, lists, one_of, tuples, dictionaries +from hypothesis.strategies import integers, just, lists, one_of, tuples from testtools import TestCase, skip -from testtools.matchers import AfterPreprocessing, Not, Equals, MatchesAll, MatchesPredicate, AllMatch +from testtools.matchers import AfterPreprocessing, Equals, MatchesAll from twisted.internet.task import Clock from twisted.python.runtime import platform @@ -51,7 +51,6 @@ from .strategies import ( lease_cancel_secrets, lease_renew_secrets, sharenum_sets, - sharenums, sizes, slot_test_and_write_vectors_for_shares, storage_indexes,