Use f-strings in many places in acme and certbot. (#9225)

This commit is contained in:
Mads Jensen
2022-03-03 07:12:34 -08:00
committed by GitHub
parent 5d493ca53c
commit 92de543fe7
13 changed files with 45 additions and 61 deletions
+1 -1
View File
@@ -279,7 +279,7 @@ class DNS01(KeyAuthorizationChallenge):
:rtype: str
"""
return "{0}.{1}".format(self.LABEL, name)
return f"{self.LABEL}.{name}"
@ChallengeResponse.register
+2 -3
View File
@@ -1142,8 +1142,7 @@ class ClientNetwork:
'response', response_ct)
if content_type == cls.JSON_CONTENT_TYPE and jobj is None:
raise errors.ClientError(
'Unexpected response Content-Type: {0}'.format(response_ct))
raise errors.ClientError(f'Unexpected response Content-Type: {response_ct}')
return response
@@ -1196,7 +1195,7 @@ class ClientNetwork:
if m is None:
raise # pragma: no cover
host, path, _err_no, err_msg = m.groups()
raise ValueError("Requesting {0}{1}:{2}".format(host, path, err_msg))
raise ValueError(f"Requesting {host}{path}:{err_msg}")
# If the Content-Type is DER or an Accept header was sent in the
# request, the response may not be UTF-8 encoded. In this case, we
+2 -3
View File
@@ -157,12 +157,11 @@ class _Constant(jose.JSONDeSerializable, Hashable):
@classmethod
def from_json(cls, jobj: str) -> '_Constant':
if jobj not in cls.POSSIBLE_NAMES: # pylint: disable=unsupported-membership-test
raise jose.DeserializationError(
'{0} not recognized'.format(cls.__name__))
raise jose.DeserializationError(f'{cls.__name__} not recognized')
return cls.POSSIBLE_NAMES[jobj]
def __repr__(self) -> str:
return '{0}({1})'.format(self.__class__.__name__, self.name)
return f'{self.__class__.__name__}({self.name})'
def __eq__(self, other: Any) -> bool:
return isinstance(other, type(self)) and other.name == self.name
+1 -1
View File
@@ -65,4 +65,4 @@ def _safe_jobj_compliance(instance: Any, jobj_method: str,
jobj.pop(uncompliant_field, None)
return jobj
raise AttributeError('Method {0}() is not implemented.'.format(jobj_method)) # pragma: no cover
raise AttributeError(f'Method {jobj_method}() is not implemented.') # pragma: no cover