diff --git a/certbot-apache/certbot_apache/_internal/configurator.py b/certbot-apache/certbot_apache/_internal/configurator.py index 59aaddbd8..944c20882 100644 --- a/certbot-apache/certbot_apache/_internal/configurator.py +++ b/certbot-apache/certbot_apache/_internal/configurator.py @@ -499,7 +499,8 @@ class ApacheConfigurator(common.Configurator): ) def deploy_cert( - self, domain: str, cert_path: str, key_path: str, chain_path: str, fullchain_path: str + self, domain: str, cert_path: str, key_path: str, + chain_path: Optional[str] = None, fullchain_path: Optional[str] = None ) -> None: """Deploys certificate to specified virtual host. @@ -1554,7 +1555,7 @@ class ApacheConfigurator(common.Configurator): self.parser.aug.set("/augeas/files%s/mtime" % (self._escape(ssl_fp)), "0") self.parser.aug.set("/augeas/files%s/mtime" % (self._escape(vhost.filep)), "0") - def _sift_rewrite_rules(self, contents: List[str]) -> Tuple[List[str], bool]: + def _sift_rewrite_rules(self, contents: Iterable[str]) -> Tuple[List[str], bool]: """ Helper function for _copy_create_ssl_vhost_skeleton to prepare the new HTTPS VirtualHost contents. Currently disabling the rewrites """ @@ -1803,7 +1804,7 @@ class ApacheConfigurator(common.Configurator): id_comment = self.parser.find_comments(search_comment, vhost.path) if id_comment: # Use the first value, multiple ones shouldn't exist - comment = self.parser.get_arg(id_comment[0]) + comment: str = self.parser.get_arg(id_comment[0]) return comment.split(" ")[-1] return None @@ -1824,7 +1825,7 @@ class ApacheConfigurator(common.Configurator): return vh_id id_string = apache_util.unique_id() - comment = constants.MANAGED_COMMENT_ID.format(id_string) + comment: str = constants.MANAGED_COMMENT_ID.format(id_string) self.parser.add_comment(vhost.path, comment) return id_string @@ -1846,8 +1847,8 @@ class ApacheConfigurator(common.Configurator): """Returns currently supported enhancements.""" return ["redirect", "ensure-http-header", "staple-ocsp"] - def enhance(self, domain: str, enhancement: Optional[Union[List[str], str]], - options: Optional[str] = None) -> None: + def enhance(self, domain: str, enhancement: str, + options: Optional[Union[List[str], str]] = None) -> None: """Enhance configuration. :param str domain: domain to enhance @@ -1877,7 +1878,7 @@ class ApacheConfigurator(common.Configurator): "enhancement was not configured.") msg_enhancement = enhancement if options: - msg_enhancement += ": " + options + msg_enhancement += ": " + str(options) msg = msg_tmpl.format(domain, msg_enhancement) logger.error(msg) raise errors.PluginError(msg) @@ -2353,7 +2354,7 @@ class ApacheConfigurator(common.Configurator): return None - def _get_proposed_addrs(self, vhost: obj.VirtualHost, port: str = "80") -> Set[Addr]: + def _get_proposed_addrs(self, vhost: obj.VirtualHost, port: str = "80") -> Iterable[Addr]: """Return all addrs of vhost with the port replaced with the specified. :param obj.VirtualHost ssl_vhost: Original Vhost diff --git a/certbot-apache/certbot_apache/_internal/obj.py b/certbot-apache/certbot_apache/_internal/obj.py index 9f185635d..2c43569cf 100644 --- a/certbot-apache/certbot_apache/_internal/obj.py +++ b/certbot-apache/certbot_apache/_internal/obj.py @@ -127,7 +127,7 @@ class VirtualHost: strip_name: Pattern = re.compile(r"^(?:.+://)?([^ :$]*)") def __init__( - self, filepath: str, path: Optional[str], addrs: AbstractSet["Addr"], + self, filepath: str, path: str, addrs: Set["Addr"], ssl: bool, enabled: bool, name: Optional[str] = None, aliases: Optional[Set[str]] = None, modmacro: bool = False, ancestor: Optional["VirtualHost"] = None, node = None): diff --git a/certbot-compatibility-test/certbot_compatibility_test/configurators/common.py b/certbot-compatibility-test/certbot_compatibility_test/configurators/common.py index 243b12612..b25d2d04b 100644 --- a/certbot-compatibility-test/certbot_compatibility_test/configurators/common.py +++ b/certbot-compatibility-test/certbot_compatibility_test/configurators/common.py @@ -8,6 +8,7 @@ import tempfile from typing import Iterable from typing import List from typing import Optional +from typing import Union from typing import overload from typing import Set from typing import Tuple @@ -121,7 +122,7 @@ class Proxy(interfaces.ConfiguratorProxy): self._configurator.config_test() def enhance(self, domain: str, enhancement: str, - options: Optional[List[str]] = None) -> None: + options: Optional[Union[List[str], str]] = None) -> None: self._configurator.enhance(domain, enhancement, options) def get_all_names(self) -> Iterable[str]: diff --git a/certbot/certbot/_internal/client.py b/certbot/certbot/_internal/client.py index 57506048b..aeeb3cf36 100644 --- a/certbot/certbot/_internal/client.py +++ b/certbot/certbot/_internal/client.py @@ -2,6 +2,7 @@ import datetime import logging import platform +from typing import Union from typing import cast from typing import Any from typing import Callable @@ -572,6 +573,7 @@ class Client: :param list domains: list of domains to install the certificate :param str privkey_path: path to certificate private key :param str cert_path: certificate file path (optional) + :param str fullchain_path: path to the full chain of the certificate :param str chain_path: chain file path """ @@ -642,13 +644,13 @@ class Client: "Option %s is not supported by the selected installer. " "Skipping enhancement.", config_name) - msg = ("We were unable to restart web server") + msg = "We were unable to restart web server" if enhanced: with error_handler.ErrorHandler(self._rollback_and_restart, msg): self.installer.restart() def apply_enhancement(self, domains: List[str], enhancement: str, - options: Optional[List[str]] = None) -> None: + options: Optional[str] = None) -> None: """Applies an enhancement on all domains. :param list domains: list of ssl_vhosts (as strings) diff --git a/certbot/certbot/_internal/plugins/null.py b/certbot/certbot/_internal/plugins/null.py index 48371021b..e79a88bb9 100644 --- a/certbot/certbot/_internal/plugins/null.py +++ b/certbot/certbot/_internal/plugins/null.py @@ -3,6 +3,7 @@ import logging from typing import Callable from typing import List from typing import Optional +from typing import Union from certbot import interfaces from certbot.plugins import common @@ -36,7 +37,7 @@ class Installer(common.Plugin, interfaces.Installer): pass # pragma: no cover def enhance(self, domain: str, enhancement: str, - options: Optional[List[str]] = None) -> None: + options: Optional[Union[List[str], str]] = None) -> None: pass # pragma: no cover def supported_enhancements(self) -> List[str]: diff --git a/certbot/certbot/interfaces.py b/certbot/certbot/interfaces.py index 52ec224cb..0d12ffd2e 100644 --- a/certbot/certbot/interfaces.py +++ b/certbot/certbot/interfaces.py @@ -5,6 +5,7 @@ from argparse import ArgumentParser import sys from types import ModuleType from typing import Any +from typing import Union from typing import cast from typing import Iterable from typing import List @@ -275,7 +276,7 @@ class Installer(Plugin): @abstractmethod def enhance(self, domain: str, enhancement: str, - options: Optional[List[str]] = None) -> None: + options: Optional[Union[List[str], str]] = None) -> None: """Perform a configuration enhancement. :param str domain: domain for which to provide enhancement diff --git a/certbot/certbot/tests/util.py b/certbot/certbot/tests/util.py index 7c01a8227..7889ded98 100644 --- a/certbot/certbot/tests/util.py +++ b/certbot/certbot/tests/util.py @@ -9,6 +9,7 @@ import sys import tempfile from typing import Any from typing import Callable +from typing import Union from typing import cast from typing import IO from typing import Iterable @@ -59,7 +60,7 @@ class DummyInstaller(common.Installer): pass def enhance(self, domain: str, enhancement: str, - options: Optional[List[str]] = None) -> None: + options: Optional[Union[List[str], str]] = None) -> None: pass def supported_enhancements(self) -> List[str]: