Add typing to certbot.apache (#9071)

* Add typing to certbot.apache

Co-authored-by: Adrien Ferrand <ferrand.ad@gmail.com>
This commit is contained in:
Mads Jensen
2022-01-21 10:15:48 +01:00
committed by GitHub
co-authored by Adrien Ferrand
parent afc5be5abe
commit 7d9e9a4900
25 changed files with 730 additions and 559 deletions
+3 -3
View File
@@ -10,7 +10,6 @@ from typing import IO
from typing import List
from typing import Optional
from typing import Tuple
from typing import Union
import warnings
from cryptography.hazmat.backends import default_backend
@@ -573,6 +572,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
"""
@@ -643,13 +643,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[Union[List[str], str]] = None) -> None:
options: Optional[str] = None) -> None:
"""Applies an enhancement on all domains.
:param list domains: list of ssl_vhosts (as strings)
+1 -1
View File
@@ -5,13 +5,13 @@ 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
from typing import Optional
from typing import Type
from typing import TYPE_CHECKING
from typing import Union
import warnings
import zope.interface
+7 -2
View File
@@ -12,6 +12,8 @@ from typing import Iterable
from typing import List
from typing import Optional
from typing import Set
from typing import Type
from typing import TypeVar
from typing import Tuple
import pkg_resources
@@ -244,6 +246,9 @@ class Configurator(Installer, interfaces.Authenticator, metaclass=ABCMeta):
"""
GenericAddr = TypeVar("GenericAddr", bound="Addr")
class Addr:
r"""Represents an virtual host address.
@@ -256,7 +261,7 @@ class Addr:
self.ipv6 = ipv6
@classmethod
def fromstring(cls, str_addr: str) -> Optional['Addr']:
def fromstring(cls: Type[GenericAddr], str_addr: str) -> Optional[GenericAddr]:
"""Initialize Addr from string."""
if str_addr.startswith('['):
# ipv6 addresses starts with [
@@ -301,7 +306,7 @@ class Addr:
"""Return port."""
return self.tup[1]
def get_addr_obj(self, port: str) -> 'Addr':
def get_addr_obj(self: GenericAddr, port: str) -> GenericAddr:
"""Return new address object with same addr and new port."""
return self.__class__((self.tup[0], port), self.ipv6)
+1 -1
View File
@@ -9,12 +9,12 @@ 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
from typing import List
from typing import Optional
from typing import Union
import unittest
import warnings