More py39 compatibility
This commit is contained in:
parent
a34de33cde
commit
423b6b62fd
|
@ -1,13 +1,15 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from typing import Union
|
||||
|
||||
from .handlers.adopt import AdoptHandler, ListAdoptablesHandler
|
||||
from .handlers.renew import RenewHandler
|
||||
from .handlers.update_tlsa import UpdateTlsaHandler
|
||||
from .utils.config import Configuration
|
||||
from .utils.parser_setup import get_parser
|
||||
|
||||
_HandlersType = \
|
||||
ListAdoptablesHandler | AdoptHandler | RenewHandler | UpdateTlsaHandler
|
||||
_HandlersType = Union[
|
||||
ListAdoptablesHandler, AdoptHandler, RenewHandler, UpdateTlsaHandler]
|
||||
|
||||
|
||||
def main() -> int:
|
||||
|
|
|
@ -3,7 +3,7 @@ from datetime import datetime, timezone
|
|||
from functools import cached_property
|
||||
from logging import getLogger
|
||||
from os.path import normpath
|
||||
from typing import Final
|
||||
from typing import Final, Optional
|
||||
|
||||
from certbot._internal.cli.cli_utils import flag_default
|
||||
from certbot._internal.client import Client
|
||||
|
@ -54,14 +54,14 @@ class _CertbotLogicEmulator(object):
|
|||
not self._certbot_config.new_key
|
||||
|
||||
@cached_property
|
||||
def _installer(self) -> Installer | None:
|
||||
def _installer(self) -> Optional[Installer]:
|
||||
installer, self._authenticator = choose_configurator_plugins(
|
||||
config=self._certbot_config, plugins=self._plugins,
|
||||
verb='renew')
|
||||
return installer
|
||||
|
||||
@cached_property
|
||||
def _authenticator(self) -> Authenticator | None:
|
||||
def _authenticator(self) -> Optional[Authenticator]:
|
||||
self._installer, authenticator = choose_configurator_plugins(
|
||||
config=self._certbot_config, plugins=self._plugins,
|
||||
verb='renew')
|
||||
|
@ -268,7 +268,8 @@ class RenewHandler(HandlerBase):
|
|||
domains = summarize_domain_list(
|
||||
domains=sorted(nonexistent_lineages))
|
||||
notify(
|
||||
msg=f'The following passed names don\'t exist: {domains}')
|
||||
msg='The following passed hostnames (lineages) are ' +
|
||||
f'not known by certbot: {domains}')
|
||||
return 1
|
||||
to_renew = {
|
||||
result.lineages[x]: result.parsed_certs[result.lineages[x]]
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
from functools import cached_property, lru_cache
|
||||
from hashlib import sha256, sha512
|
||||
from logging import getLogger
|
||||
from typing import Literal, Mapping
|
||||
from typing import Literal, Mapping, Optional
|
||||
|
||||
from certbot._internal.storage import (
|
||||
ALL_FOUR, BASE_PRIVKEY_MODE, RenewableCert, config_with_defaults,
|
||||
|
@ -229,7 +229,7 @@ class DaneCert(RenewableCert):
|
|||
return load_pem_x509_certificate(data=data)
|
||||
|
||||
@cached_property
|
||||
def __upcoming_pubcert(self) -> Certificate | None:
|
||||
def __upcoming_pubcert(self) -> Optional[Certificate]:
|
||||
if not self.all_upcomings_in_place:
|
||||
return
|
||||
data = Path(self.all_upcomings_in_place['cert']).read_bytes()
|
||||
|
|
|
@ -8,7 +8,7 @@ from ipaddress import IPv4Address, IPv6Address, ip_address
|
|||
from os import W_OK, access
|
||||
from pathlib import Path
|
||||
from pprint import pformat
|
||||
from typing import Any, Literal, TypedDict, get_origin
|
||||
from typing import Any, Literal, Optional, TypedDict, Union, get_origin
|
||||
|
||||
from dns.name import Name
|
||||
from dns.tsig import Key
|
||||
|
@ -145,7 +145,7 @@ class _DnsUpdateServerTsigConf(object):
|
|||
|
||||
@dataclass
|
||||
class _DnsUpdateServerConf(object):
|
||||
ip: IPv4Address | IPv6Address
|
||||
ip: Union[IPv4Address, IPv6Address]
|
||||
tsig: _DnsUpdateServerTsigConf
|
||||
|
||||
@staticmethod
|
||||
|
@ -159,20 +159,20 @@ class _DnsUpdateServerConf(object):
|
|||
@dataclass
|
||||
class _DnsServerInfo(object):
|
||||
'Collected information about one DNS server.'
|
||||
ip: IPv4Address | IPv6Address
|
||||
tsig: _DnsUpdateServerTsigConf | AdoptedCertServeritemTsigConfig
|
||||
ip: Union[IPv4Address, IPv6Address]
|
||||
tsig: Union[_DnsUpdateServerTsigConf, AdoptedCertServeritemTsigConfig]
|
||||
|
||||
|
||||
@dataclass
|
||||
class _DnsUpdateConf(object):
|
||||
'`dns-update` section of the configuration.'
|
||||
servers: dict[IPv4Address | IPv6Address, _DnsUpdateServerConf]
|
||||
servers: dict[Union[IPv4Address, IPv6Address], _DnsUpdateServerConf]
|
||||
|
||||
@staticmethod
|
||||
def parse(data: DnsUpdateDict) -> _DnsUpdateConf:
|
||||
'Return a parsed version from yaml data.'
|
||||
check_required_keys(data=data, datatype=DnsUpdateDict)
|
||||
servers = dict[IPv4Address | IPv6Address, _DnsUpdateServerConf]()
|
||||
servers = dict[Union[IPv4Address, IPv6Address], _DnsUpdateServerConf]()
|
||||
for item in data['servers']:
|
||||
parsed = _DnsUpdateServerConf.parse(data=item)
|
||||
servers[parsed.ip] = parsed
|
||||
|
@ -256,8 +256,8 @@ class AdoptedCertServeritemTsigConfig(object):
|
|||
@dataclass
|
||||
class AdoptedCertHostitemServeritemConfig(object):
|
||||
'One server configuration for one adopted certificate.'
|
||||
ip: IPv4Address | IPv6Address
|
||||
tsig: AdoptedCertServeritemTsigConfig | None
|
||||
ip: Union[IPv4Address, IPv6Address]
|
||||
tsig: Optional[AdoptedCertServeritemTsigConfig]
|
||||
|
||||
@staticmethod
|
||||
def parse(
|
||||
|
@ -294,9 +294,9 @@ class AdoptedCertHostitemServeritemConfig(object):
|
|||
class AdoptedCertHostitemRecordsitemConfig(object):
|
||||
protocol: TlsaProtocol
|
||||
number: int
|
||||
usage: list[TlsaUsage] | None
|
||||
selector: list[TlsaSelector] | None
|
||||
matching_type: list[TlsaMatchingType] | None
|
||||
usage: Optional[list[TlsaUsage]]
|
||||
selector: Optional[list[TlsaSelector]]
|
||||
matching_type: Optional[list[TlsaMatchingType]]
|
||||
|
||||
@staticmethod
|
||||
def parse(
|
||||
|
@ -336,11 +336,11 @@ class AdoptedCertHostitemRecordsitemConfig(object):
|
|||
class AdoptedCertHostitemConfig(object):
|
||||
'One host configuration for an adopted certificate.'
|
||||
name: str
|
||||
zone: str | None
|
||||
records: list[AdoptedCertHostitemRecordsitemConfig] | None
|
||||
ttl: int | None
|
||||
time_to_reload: int | None
|
||||
servers: list[AdoptedCertHostitemServeritemConfig] | None
|
||||
zone: Optional[str]
|
||||
records: Optional[list[AdoptedCertHostitemRecordsitemConfig]]
|
||||
ttl: Optional[int]
|
||||
time_to_reload: Optional[int]
|
||||
servers: Optional[list[AdoptedCertHostitemServeritemConfig]]
|
||||
|
||||
@staticmethod
|
||||
def parse(item: RuntimeAdopteditemHostDict) -> AdoptedCertHostitemConfig:
|
||||
|
|
|
@ -6,6 +6,7 @@ from functools import cached_property
|
|||
from ipaddress import IPv4Address, IPv6Address
|
||||
from itertools import product
|
||||
from logging import getLogger
|
||||
from typing import Optional, Union
|
||||
|
||||
from certbot.display.util import notify
|
||||
from certbot.errors import ConfigurationError
|
||||
|
@ -61,7 +62,7 @@ class _DnsServerTsig(object):
|
|||
|
||||
@dataclass
|
||||
class _DnsServerInfo(object):
|
||||
ip: IPv4Address | IPv6Address
|
||||
ip: Union[IPv4Address, IPv6Address]
|
||||
tsig: _DnsServerTsig
|
||||
|
||||
@staticmethod
|
||||
|
@ -264,7 +265,7 @@ class _FqdnHostname(object):
|
|||
@staticmethod
|
||||
def construct(
|
||||
prefix: _TlsaHostPrefix, name: str, zone: str,
|
||||
domain: str | None = None
|
||||
domain: Optional[str] = None
|
||||
) -> _FqdnHostname:
|
||||
return _FqdnHostname(
|
||||
prefix=prefix, hostname=name, zone=zone, domain=domain or zone)
|
||||
|
|
Loading…
Reference in New Issue