Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/certbot/certbot.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/acme
diff options
context:
space:
mode:
authorAdrien Ferrand <adferrand@users.noreply.github.com>2021-03-10 22:51:27 +0300
committerGitHub <noreply@github.com>2021-03-10 22:51:27 +0300
commitdd6f2f565e8183b69ff3abf5d965d0d1575b2e5e (patch)
tree9c7547ddedba4a9a5d489780c916c1cf98500ae5 /acme
parentf2d8c81e9b8165a37c27641a49b447e55921147e (diff)
Convert Python 2 type hints to Python 3 types annotations (#8640)
Fixes #8427 This PR converts the Python 2 types hints into Python 3 types annotations. I have used the project https://github.com/ilevkivskyi/com2ann which has been designed for that specific purpose and did that very well. The only remaining things to do were to fix broken type hints that became wrong code after migration, and to fix lines too long with the new syntax. * Raw execution of com2ann * Fixing broken type annotations * Cleanup imports
Diffstat (limited to 'acme')
-rw-r--r--acme/acme/challenges.py4
-rw-r--r--acme/acme/client.py11
-rw-r--r--acme/acme/crypto_util.py4
-rw-r--r--acme/acme/messages.py6
-rw-r--r--acme/acme/standalone.py4
-rw-r--r--acme/tests/client_test.py2
-rw-r--r--acme/tests/crypto_util_test.py2
-rw-r--r--acme/tests/messages_test.py3
-rw-r--r--acme/tests/standalone_test.py4
9 files changed, 21 insertions, 19 deletions
diff --git a/acme/acme/challenges.py b/acme/acme/challenges.py
index 58b457e0d..82f7ae1b8 100644
--- a/acme/acme/challenges.py
+++ b/acme/acme/challenges.py
@@ -24,7 +24,7 @@ logger = logging.getLogger(__name__)
class Challenge(jose.TypedJSONObjectWithFields):
# _fields_to_partial_json
"""ACME challenge."""
- TYPES = {} # type: dict
+ TYPES: dict = {}
@classmethod
def from_json(cls, jobj):
@@ -38,7 +38,7 @@ class Challenge(jose.TypedJSONObjectWithFields):
class ChallengeResponse(ResourceMixin, TypeMixin, jose.TypedJSONObjectWithFields):
# _fields_to_partial_json
"""ACME challenge response."""
- TYPES = {} # type: dict
+ TYPES: dict = {}
resource_type = 'challenge'
resource = fields.Resource(resource_type)
diff --git a/acme/acme/client.py b/acme/acme/client.py
index b1b2089cf..f5aa1ff9e 100644
--- a/acme/acme/client.py
+++ b/acme/acme/client.py
@@ -112,8 +112,9 @@ class ClientBase:
"""
return self.update_registration(regr, update={'status': 'deactivated'})
- def deactivate_authorization(self, authzr):
- # type: (messages.AuthorizationResource) -> messages.AuthorizationResource
+ def deactivate_authorization(self,
+ authzr: messages.AuthorizationResource
+ ) -> messages.AuthorizationResource:
"""Deactivate authorization.
:param messages.AuthorizationResource authzr: The Authorization resource
@@ -423,7 +424,7 @@ class Client(ClientBase):
"""
assert max_attempts > 0
- attempts = collections.defaultdict(int) # type: Dict[messages.AuthorizationResource, int]
+ attempts: Dict[messages.AuthorizationResource, int] = collections.defaultdict(int)
exhausted = set()
# priority queue with datetime.datetime (based on Retry-After) as key,
@@ -536,7 +537,7 @@ class Client(ClientBase):
:rtype: `list` of `OpenSSL.crypto.X509` wrapped in `.ComparableX509`
"""
- chain = [] # type: List[jose.ComparableX509]
+ chain: List[jose.ComparableX509] = []
uri = certr.cert_chain_uri
while uri is not None and len(chain) < max_length:
response, cert = self._get_cert(uri)
@@ -968,7 +969,7 @@ class ClientNetwork:
self.account = account
self.alg = alg
self.verify_ssl = verify_ssl
- self._nonces = set() # type: Set[Text]
+ self._nonces: Set[Text] = set()
self.user_agent = user_agent
self.session = requests.Session()
self._default_timeout = timeout
diff --git a/acme/acme/crypto_util.py b/acme/acme/crypto_util.py
index 04faf6912..749478bf5 100644
--- a/acme/acme/crypto_util.py
+++ b/acme/acme/crypto_util.py
@@ -168,7 +168,7 @@ def probe_sni(name, host, port=443, timeout=300, # pylint: disable=too-many-argu
source_address[1]
) if any(source_address) else ""
)
- socket_tuple = (host, port) # type: Tuple[str, int]
+ socket_tuple: Tuple[str, int] = (host, port)
sock = socket.create_connection(socket_tuple, **socket_kwargs) # type: ignore
except socket.error as error:
raise errors.Error(error)
@@ -256,7 +256,7 @@ def _pyopenssl_cert_or_req_san(cert_or_req):
if isinstance(cert_or_req, crypto.X509):
# pylint: disable=line-too-long
- func = crypto.dump_certificate # type: Union[Callable[[int, crypto.X509Req], bytes], Callable[[int, crypto.X509], bytes]]
+ func: Union[Callable[[int, crypto.X509Req], bytes], Callable[[int, crypto.X509], bytes]] = crypto.dump_certificate
else:
func = crypto.dump_certificate_request
text = func(crypto.FILETYPE_TEXT, cert_or_req).decode("utf-8")
diff --git a/acme/acme/messages.py b/acme/acme/messages.py
index 0d73037ae..5e7e22c34 100644
--- a/acme/acme/messages.py
+++ b/acme/acme/messages.py
@@ -153,7 +153,7 @@ class _Constant(jose.JSONDeSerializable, Hashable): # type: ignore
class Status(_Constant):
"""ACME "status" field."""
- POSSIBLE_NAMES = {} # type: dict
+ POSSIBLE_NAMES: dict = {}
STATUS_UNKNOWN = Status('unknown')
STATUS_PENDING = Status('pending')
STATUS_PROCESSING = Status('processing')
@@ -166,7 +166,7 @@ STATUS_DEACTIVATED = Status('deactivated')
class IdentifierType(_Constant):
"""ACME identifier type."""
- POSSIBLE_NAMES = {} # type: dict
+ POSSIBLE_NAMES: dict = {}
IDENTIFIER_FQDN = IdentifierType('dns') # IdentifierDNS in Boulder
@@ -184,7 +184,7 @@ class Identifier(jose.JSONObjectWithFields):
class Directory(jose.JSONDeSerializable):
"""Directory."""
- _REGISTERED_TYPES = {} # type: dict
+ _REGISTERED_TYPES: dict = {}
class Meta(jose.JSONObjectWithFields):
"""Directory Meta."""
diff --git a/acme/acme/standalone.py b/acme/acme/standalone.py
index 123899470..0b5a8b5c7 100644
--- a/acme/acme/standalone.py
+++ b/acme/acme/standalone.py
@@ -63,8 +63,8 @@ class BaseDualNetworkedServers:
def __init__(self, ServerClass, server_address, *remaining_args, **kwargs):
port = server_address[1]
- self.threads = [] # type: List[threading.Thread]
- self.servers = [] # type: List[ACMEServerMixin]
+ self.threads: List[threading.Thread] = []
+ self.servers: List[ACMEServerMixin] = []
# Must try True first.
# Ubuntu, for example, will fail to bind to IPv4 if we've already bound
diff --git a/acme/tests/client_test.py b/acme/tests/client_test.py
index 6f9aecda2..14247335c 100644
--- a/acme/tests/client_test.py
+++ b/acme/tests/client_test.py
@@ -61,7 +61,7 @@ class ClientTestBase(unittest.TestCase):
self.contact = ('mailto:cert-admin@example.com', 'tel:+12025551212')
reg = messages.Registration(
contact=self.contact, key=KEY.public_key())
- the_arg = dict(reg) # type: Dict
+ the_arg: Dict = dict(reg)
self.new_reg = messages.NewRegistration(**the_arg)
self.regr = messages.RegistrationResource(
body=reg, uri='https://www.letsencrypt-demo.org/acme/reg/1')
diff --git a/acme/tests/crypto_util_test.py b/acme/tests/crypto_util_test.py
index f271ad37d..8075b68ed 100644
--- a/acme/tests/crypto_util_test.py
+++ b/acme/tests/crypto_util_test.py
@@ -180,7 +180,7 @@ class RandomSnTest(unittest.TestCase):
def setUp(self):
self.cert_count = 5
- self.serial_num = [] # type: List[int]
+ self.serial_num: List[int] = []
self.key = OpenSSL.crypto.PKey()
self.key.generate_key(OpenSSL.crypto.TYPE_RSA, 2048)
diff --git a/acme/tests/messages_test.py b/acme/tests/messages_test.py
index 74d1737ec..99a3a9ce4 100644
--- a/acme/tests/messages_test.py
+++ b/acme/tests/messages_test.py
@@ -1,4 +1,5 @@
"""Tests for acme.messages."""
+from typing import Dict
import unittest
from unittest import mock
@@ -81,7 +82,7 @@ class ConstantTest(unittest.TestCase):
from acme.messages import _Constant
class MockConstant(_Constant): # pylint: disable=missing-docstring
- POSSIBLE_NAMES = {} # type: Dict
+ POSSIBLE_NAMES: Dict = {}
self.MockConstant = MockConstant # pylint: disable=invalid-name
self.const_a = MockConstant('a')
diff --git a/acme/tests/standalone_test.py b/acme/tests/standalone_test.py
index e6aa8f2d6..a02d008a0 100644
--- a/acme/tests/standalone_test.py
+++ b/acme/tests/standalone_test.py
@@ -41,7 +41,7 @@ class HTTP01ServerTest(unittest.TestCase):
def setUp(self):
self.account_key = jose.JWK.load(
test_util.load_vector('rsa1024_key.pem'))
- self.resources = set() # type: Set
+ self.resources: Set = set()
from acme.standalone import HTTP01Server
self.server = HTTP01Server(('', 0), resources=self.resources)
@@ -218,7 +218,7 @@ class HTTP01DualNetworkedServersTest(unittest.TestCase):
def setUp(self):
self.account_key = jose.JWK.load(
test_util.load_vector('rsa1024_key.pem'))
- self.resources = set() # type: Set
+ self.resources: Set = set()
from acme.standalone import HTTP01DualNetworkedServers
self.servers = HTTP01DualNetworkedServers(('', 0), resources=self.resources)