fix new mypy complaints

This commit is contained in:
Alex Zorin
2022-11-11 18:03:57 +11:00
parent 1773edcad0
commit 202db15274
9 changed files with 14 additions and 12 deletions
@@ -118,7 +118,8 @@ class ApacheBlockNode(ApacheDirectiveNode):
# pylint: disable=unused-argument
def add_child_directive(self, name: str, parameters: Optional[List[str]] = None,
position: int = None) -> ApacheDirectiveNode: # pragma: no cover
position: Optional[int] = None
) -> ApacheDirectiveNode: # pragma: no cover
"""Adds a new DirectiveNode to the sequence of children"""
new_dir = ApacheDirectiveNode(name=assertions.PASS,
parameters=assertions.PASS,
@@ -812,7 +812,7 @@ class ApacheConfigurator(common.Configurator):
return self._find_best_vhost(target, filtered_vhosts, filter_defaults)
def _find_best_vhost(
self, target_name: str, vhosts: List[obj.VirtualHost] = None,
self, target_name: str, vhosts: Optional[List[obj.VirtualHost]] = None,
filter_defaults: bool = True
) -> Optional[obj.VirtualHost]:
"""Finds the best vhost for a target_name.
@@ -17,8 +17,8 @@ class IntegrationTestsContext:
self.request = request
if hasattr(request.config, 'workerinput'): # Worker node
self.worker_id = request.config.workerinput['workerid'] # type: ignore[attr-defined]
acme_xdist = request.config.workerinput['acme_xdist'] # type: ignore[attr-defined]
self.worker_id = request.config.workerinput['workerid']
acme_xdist = request.config.workerinput['acme_xdist']
else: # Primary node
self.worker_id = 'primary'
acme_xdist = request.config.acme_xdist # type: ignore[attr-defined]
@@ -21,7 +21,7 @@ class IntegrationTestsContext(certbot_context.IntegrationTestsContext):
self.request = request
if hasattr(request.config, 'workerinput'): # Worker node
self._dns_xdist = request.config.workerinput['dns_xdist'] # type: ignore[attr-defined]
self._dns_xdist = request.config.workerinput['dns_xdist']
else: # Primary node
self._dns_xdist = request.config.dns_xdist # type: ignore[attr-defined]
@@ -1112,7 +1112,7 @@ class NginxConfigurator(common.Configurator):
###################################################
# Wrapper functions for Reverter class (Installer)
###################################################
def save(self, title: str = None, temporary: bool = False) -> None:
def save(self, title: Optional[str] = None, temporary: bool = False) -> None:
"""Saves all changes to the configuration files.
:param str title: The title of the save. If a title is given, the
+1 -1
View File
@@ -108,7 +108,7 @@ class Account:
class AccountMemoryStorage(interfaces.AccountStorage):
"""In-memory account storage."""
def __init__(self, initial_accounts: Dict[str, Account] = None) -> None:
def __init__(self, initial_accounts: Optional[Dict[str, Account]] = None) -> None:
self.accounts = initial_accounts if initial_accounts is not None else {}
def find_all(self) -> List[Account]:
@@ -11,6 +11,7 @@ def get_completer() -> Optional[Callable[[], str]]:
def get_completer_delims() -> List[str]:
"""An empty implementation of readline.get_completer_delims."""
return []
def parse_and_bind(unused_command: str) -> None:
+1 -1
View File
@@ -1683,7 +1683,7 @@ def make_displayer(config: configuration.NamespaceConfig
devnull.close()
def main(cli_args: List[str] = None) -> Optional[Union[str, int]]:
def main(cli_args: Optional[List[str]] = None) -> Optional[Union[str, int]]:
"""Run Certbot.
:param cli_args: command line to Certbot, defaults to ``sys.argv[1:]``
+4 -4
View File
@@ -39,7 +39,7 @@ from certbot.plugins import common
class DummyInstaller(common.Installer):
"""Dummy installer plugin for test purpose."""
def get_all_names(self) -> Iterable[str]:
pass
return []
def deploy_cert(self, domain: str, cert_path: str, key_path: str, chain_path: str,
fullchain_path: str) -> None:
@@ -50,7 +50,7 @@ class DummyInstaller(common.Installer):
pass
def supported_enhancements(self) -> List[str]:
pass
return []
def save(self, title: Optional[str] = None, temporary: bool = False) -> None:
pass
@@ -69,7 +69,7 @@ class DummyInstaller(common.Installer):
pass
def more_info(self) -> str:
pass
return ""
def vector_path(*names: str) -> str:
@@ -253,7 +253,7 @@ class FreezableMock:
value of func is ignored.
"""
def __init__(self, frozen: bool = False, func: Callable[..., Any] = None,
def __init__(self, frozen: bool = False, func: Optional[Callable[..., Any]] = None,
return_value: Any = mock.sentinel.DEFAULT) -> None:
self._frozen_set = set() if frozen else {'freeze', }
self._func = func