From 6ea5da51e08c12bc3a2811a737be94f6c1410bbe Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 6 Jan 2025 16:18:28 -0500 Subject: [PATCH] Simplify typing for a local variable (#10113) `_DefaultCertSelection` _is_ a `Callable` of the appropriate signature. Also fixed a mypy error I see locally, `TOKEN_SIZE` should be an integer. --- acme/acme/challenges.py | 2 +- acme/acme/crypto_util.py | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/acme/acme/challenges.py b/acme/acme/challenges.py index 818df9032..e30c6452a 100644 --- a/acme/acme/challenges.py +++ b/acme/acme/challenges.py @@ -89,7 +89,7 @@ class _TokenChallenge(Challenge): :ivar bytes token: """ - TOKEN_SIZE = 128 / 8 # Based on the entropy value from the spec + TOKEN_SIZE = 128 // 8 # Based on the entropy value from the spec """Minimum size of the :attr:`token` in bytes.""" # TODO: acme-spec doesn't specify token as base64-encoded value diff --git a/acme/acme/crypto_util.py b/acme/acme/crypto_util.py index 77b6260c6..967130a76 100644 --- a/acme/acme/crypto_util.py +++ b/acme/acme/crypto_util.py @@ -95,13 +95,9 @@ class SSLSocket: # pylint: disable=too-few-public-methods raise ValueError("Neither cert_selection or certs specified.") if cert_selection and certs: raise ValueError("Both cert_selection and certs specified.") - actual_cert_selection: Union[_DefaultCertSelection, - Optional[Callable[[SSL.Connection], - Optional[Tuple[crypto.PKey, - crypto.X509]]]]] = cert_selection - if actual_cert_selection is None: - actual_cert_selection = _DefaultCertSelection(certs if certs else {}) - self.cert_selection = actual_cert_selection + if cert_selection is None: + cert_selection = _DefaultCertSelection(certs if certs else {}) + self.cert_selection = cert_selection def __getattr__(self, name: str) -> Any: return getattr(self.sock, name)