diff --git a/certbot-apache/certbot_apache/_internal/apache_util.py b/certbot-apache/certbot_apache/_internal/apache_util.py index 561dc558c..850bdb7f5 100644 --- a/certbot-apache/certbot_apache/_internal/apache_util.py +++ b/certbot-apache/certbot_apache/_internal/apache_util.py @@ -82,7 +82,7 @@ def _split_aug_path(vhost_path: str) -> Tuple[str, str]: """ # Strip off /files - file_path: str = vhost_path[6:] + file_path = vhost_path[6:] internal_path: List[str] = [] # Remove components from the end of file_path until it becomes valid diff --git a/certbot-apache/certbot_apache/_internal/configurator.py b/certbot-apache/certbot_apache/_internal/configurator.py index a37755613..c2adeab13 100644 --- a/certbot-apache/certbot_apache/_internal/configurator.py +++ b/certbot-apache/certbot_apache/_internal/configurator.py @@ -31,6 +31,7 @@ from certbot.compat import os from certbot.display import util as display_util from certbot.interfaces import RenewableCert from certbot.plugins import common +from certbot.plugins.common import Addr from certbot.plugins.enhancements import AutoHSTSEnhancement from certbot.plugins.util import path_surgery from certbot_apache._internal import apache_util @@ -735,7 +736,7 @@ class ApacheConfigurator(common.Configurator): def _choose_vhost_from_list(self, target_name: str, temp: bool = False) -> obj.VirtualHost: # Select a vhost from a list - vhost: obj.VirtualHost = display_ops.select_vhost(target_name, self.vhosts) + vhost = display_ops.select_vhost(target_name, self.vhosts) if vhost is None: self._raise_no_suitable_vhost_error(target_name) if temp: @@ -973,7 +974,7 @@ class ApacheConfigurator(common.Configurator): :rtype: :class:`~certbot_apache._internal.obj.VirtualHost` """ - addrs: Set[obj.Addr] = set() + addrs: Set[Addr] = set() try: args = self.parser.aug.match(path + "/arg") except RuntimeError: @@ -1691,7 +1692,7 @@ class ApacheConfigurator(common.Configurator): vh_path, False) self.parser.aug.remove(re.sub(r"/\w*$", "", directive_path[0])) - def _add_dummy_ssl_directives(self, vh_path: Optional[str]) -> None: + def _add_dummy_ssl_directives(self, vh_path: str) -> None: self.parser.add_dir(vh_path, "SSLCertificateFile", "insert_cert_file_path") self.parser.add_dir(vh_path, "SSLCertificateKeyFile", @@ -2516,7 +2517,7 @@ class ApacheConfigurator(common.Configurator): def perform( self, achalls: List[KeyAuthorizationAnnotatedChallenge] - ) -> Sequence[Optional[challenges.HTTP01Response]]: + ) -> List[Challenge]: """Perform the configuration related challenge. This function currently assumes all challenges will be fulfilled. @@ -2551,7 +2552,7 @@ class ApacheConfigurator(common.Configurator): def _update_responses( self, - responses: Sequence[challenges.HTTP01Response], + responses: Iterable[challenges.HTTP01Response], chall_response: List[Challenge], chall_doer: http_01.ApacheHttp01 ) -> None: diff --git a/certbot-apache/certbot_apache/_internal/http_01.py b/certbot-apache/certbot_apache/_internal/http_01.py index 6b27be026..a3f2d1a20 100644 --- a/certbot-apache/certbot_apache/_internal/http_01.py +++ b/certbot-apache/certbot_apache/_internal/http_01.py @@ -69,7 +69,7 @@ class ApacheHttp01(common.ChallengePerformer): "http_challenges") self.moded_vhosts: Set[VirtualHost] = set() - def perform(self) -> Sequence[Optional[HTTP01Response]]: + def perform(self) -> List[KeyAuthorizationAnnotatedChallenge]: """Perform all HTTP-01 challenges.""" if not self.achalls: return [] diff --git a/certbot-apache/certbot_apache/_internal/obj.py b/certbot-apache/certbot_apache/_internal/obj.py index 738625d31..c206a42cb 100644 --- a/certbot-apache/certbot_apache/_internal/obj.py +++ b/certbot-apache/certbot_apache/_internal/obj.py @@ -83,7 +83,7 @@ class Addr(common.Addr): """Returns if address has a wildcard port.""" return self.tup[1] == "*" or not self.tup[1] - def get_sni_addr(self, port: str) -> "Addr": + def get_sni_addr(self, port: str) -> common.Addr: """Returns the least specific address that resolves on the port. Examples: @@ -126,7 +126,7 @@ class VirtualHost: strip_name: Pattern = re.compile(r"^(?:.+://)?([^ :$]*)") def __init__( - self, filepath: str, path: Optional[str], addrs: Set[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-apache/certbot_apache/_internal/parser.py b/certbot-apache/certbot_apache/_internal/parser.py index 79aecc0af..49fa9617a 100644 --- a/certbot-apache/certbot_apache/_internal/parser.py +++ b/certbot-apache/certbot_apache/_internal/parser.py @@ -55,7 +55,7 @@ class ApacheParser: # Needed for calling save() with reverter functionality that resides in # AugeasConfigurator superclass of ApacheConfigurator. This resolves # issues with aug.load() after adding new files / defines to parse tree - self.configurator: "ApacheConfigurator" = configurator + self.configurator = configurator # Initialize augeas self.aug: Augeas = init_augeas() @@ -424,7 +424,7 @@ class ApacheParser: return retpath def add_dir( - self, aug_conf_path: Optional[str], directive: Optional[str], args: Union[List[str], str] + self, aug_conf_path: str, directive: Optional[str], args: Union[List[str], str] ) -> None: """Appends directive to the end fo the file given by aug_conf_path. @@ -437,7 +437,7 @@ class ApacheParser: :type args: list or str """ - self.aug.set(aug_conf_path or "" + "/directive[last() + 1]", directive) + self.aug.set(aug_conf_path + "/directive[last() + 1]", directive) if isinstance(args, list): for i, value in enumerate(args, 1): self.aug.set( @@ -590,7 +590,7 @@ class ApacheParser: allargs = self.aug.match(match + '*') return [self.get_arg(arg) for arg in allargs] - def get_arg(self, match: Optional[str]) -> Optional[str]: + def get_arg(self, match: Optional[str]) -> str: """Uses augeas.get to get argument value and interprets result. This also converts all variables and parameters appropriately. @@ -624,7 +624,7 @@ class ApacheParser: """ return get_aug_path(self.loc["root"]) - def exclude_dirs(self, matches: Set[str]): + def exclude_dirs(self, matches: Set[str]) -> List[str]: """Exclude directives that are not loaded into the configuration.""" filters = [("ifmodule", self.modules.keys()), ("ifdefine", self.variables)] @@ -786,7 +786,7 @@ class ApacheParser: """ return self._parsed_by_parser_paths(filep, self.parser_paths) - def parsed_in_original(self, filep: Optional[str]) -> bool: + def parsed_in_original(self, filep: str) -> bool: """Checks if the file path is parsed by existing Apache config. ie. returns True if the file is found on a path that matches Include or IncludeOptional statement in the Apache configuration.