mirror of
https://github.com/certbot/certbot.git
synced 2026-05-28 04:34:11 -04:00
Use literals wherever possible. (#9194)
* Use literals wherever possible. These were found with flake8-comprehensions.
This commit is contained in:
parent
a1b2e973c0
commit
6f85eb928c
11 changed files with 37 additions and 32 deletions
|
|
@ -65,11 +65,11 @@ ERROR_CODES = {
|
|||
'externalAccountRequired': 'The server requires external account binding',
|
||||
}
|
||||
|
||||
ERROR_TYPE_DESCRIPTIONS = dict(
|
||||
(ERROR_PREFIX + name, desc) for name, desc in ERROR_CODES.items())
|
||||
|
||||
ERROR_TYPE_DESCRIPTIONS.update(dict( # add errors with old prefix, deprecate me
|
||||
(OLD_ERROR_PREFIX + name, desc) for name, desc in ERROR_CODES.items()))
|
||||
ERROR_TYPE_DESCRIPTIONS = {**{
|
||||
ERROR_PREFIX + name: desc for name, desc in ERROR_CODES.items()
|
||||
}, **{ # add errors with old prefix, deprecate me
|
||||
OLD_ERROR_PREFIX + name: desc for name, desc in ERROR_CODES.items()
|
||||
}}
|
||||
|
||||
|
||||
def is_acme_error(err: BaseException) -> bool:
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ def _get_names(config: str) -> Tuple[Set[str], Set[str]]:
|
|||
for this_file in files:
|
||||
update_names = _get_server_names(root, this_file)
|
||||
all_names.update(update_names)
|
||||
non_ip_names = set(n for n in all_names if not util.IP_REGEX.match(n))
|
||||
non_ip_names = {n for n in all_names if not util.IP_REGEX.match(n)}
|
||||
return all_names, non_ip_names
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ elif platform.system() in ('NetBSD',):
|
|||
else:
|
||||
server_root_tmp = LINUX_SERVER_ROOT
|
||||
|
||||
CLI_DEFAULTS: Dict[str, Any] = dict(
|
||||
server_root=server_root_tmp,
|
||||
ctl="nginx",
|
||||
sleep_seconds=1
|
||||
)
|
||||
CLI_DEFAULTS: Dict[str, Any] = {
|
||||
"server_root": server_root_tmp,
|
||||
"ctl": "nginx",
|
||||
"sleep_seconds": 1
|
||||
}
|
||||
"""CLI defaults."""
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ class AuthHandler:
|
|||
# Make sure to make a copy...
|
||||
plugin_pref = self.auth.get_chall_pref(domain)
|
||||
if self.pref_challs:
|
||||
plugin_pref_types = set(chall.typ for chall in plugin_pref)
|
||||
plugin_pref_types = {chall.typ for chall in plugin_pref}
|
||||
for typ in self.pref_challs:
|
||||
if typ in plugin_pref_types:
|
||||
chall_prefs.append(challenges.Challenge.TYPES[typ])
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ class Client:
|
|||
|
||||
orderr = self._get_order_and_authorizations(csr.data, self.config.allow_subset_of_names)
|
||||
authzr = orderr.authorizations
|
||||
auth_domains = set(a.body.identifier.value for a in authzr)
|
||||
auth_domains = {a.body.identifier.value for a in authzr}
|
||||
successful_domains = [d for d in domains if d in auth_domains]
|
||||
|
||||
# allow_subset_of_names is currently disabled for wildcard
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ SETUPTOOLS_PLUGINS_ENTRY_POINT = "certbot.plugins"
|
|||
OLD_SETUPTOOLS_PLUGINS_ENTRY_POINT = "letsencrypt.plugins"
|
||||
"""Plugins Setuptools entry point before rename."""
|
||||
|
||||
CLI_DEFAULTS: Dict[str, Any] = dict(
|
||||
CLI_DEFAULTS: Dict[str, Any] = dict( # noqa
|
||||
config_files=[
|
||||
os.path.join(misc.get_default_folder('config'), 'cli.ini'),
|
||||
# https://freedesktop.org/wiki/Software/xdg-user-dirs/
|
||||
|
|
@ -149,13 +149,13 @@ QUIET_LOGGING_LEVEL = logging.ERROR
|
|||
DEFAULT_LOGGING_LEVEL = logging.WARNING
|
||||
"""Default logging level to use when not in quiet mode."""
|
||||
|
||||
RENEWER_DEFAULTS = dict(
|
||||
renewer_enabled="yes",
|
||||
renew_before_expiry="30 days",
|
||||
RENEWER_DEFAULTS = {
|
||||
"renewer_enabled": "yes",
|
||||
"renew_before_expiry": "30 days",
|
||||
# This value should ensure that there is never a deployment delay by
|
||||
# default.
|
||||
deploy_before_expiry="99 years",
|
||||
)
|
||||
"deploy_before_expiry": "99 years",
|
||||
}
|
||||
"""Defaults for renewer script."""
|
||||
|
||||
ARCHIVE_DIR = "archive"
|
||||
|
|
|
|||
|
|
@ -189,10 +189,12 @@ permitted by DNS standards.)
|
|||
|
||||
def _perform_achall_with_script(self, achall: achallenges.AnnotatedChallenge,
|
||||
achalls: List[achallenges.AnnotatedChallenge]) -> None:
|
||||
env = dict(CERTBOT_DOMAIN=achall.domain,
|
||||
CERTBOT_VALIDATION=achall.validation(achall.account_key),
|
||||
CERTBOT_ALL_DOMAINS=','.join(one_achall.domain for one_achall in achalls),
|
||||
CERTBOT_REMAINING_CHALLENGES=str(len(achalls) - achalls.index(achall) - 1))
|
||||
env = {
|
||||
"CERTBOT_DOMAIN": achall.domain,
|
||||
"CERTBOT_VALIDATION": achall.validation(achall.account_key),
|
||||
"CERTBOT_ALL_DOMAINS": ','.join(one_achall.domain for one_achall in achalls),
|
||||
"CERTBOT_REMAINING_CHALLENGES": str(len(achalls) - achalls.index(achall) - 1),
|
||||
}
|
||||
if isinstance(achall.chall, challenges.HTTP01):
|
||||
env['CERTBOT_TOKEN'] = achall.chall.encode('token')
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -289,10 +289,11 @@ def relevant_values(all_values: Mapping[str, Any]) -> Dict[str, Any]:
|
|||
plugins = plugins_disco.PluginsRegistry.find_all()
|
||||
namespaces = [plugins_common.dest_namespace(plugin) for plugin in plugins]
|
||||
|
||||
rv = dict(
|
||||
(option, value)
|
||||
rv = {
|
||||
option: value
|
||||
for option, value in all_values.items()
|
||||
if _relevant(namespaces, option) and cli.option_was_set(option, value))
|
||||
if _relevant(namespaces, option) and cli.option_was_set(option, value)
|
||||
}
|
||||
# We always save the server value to help with forward compatibility
|
||||
# and behavioral consistency when versions of Certbot with different
|
||||
# server defaults are used.
|
||||
|
|
|
|||
|
|
@ -320,9 +320,10 @@ class RenewalHookTest(HookTest):
|
|||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.vars_to_clear = set(
|
||||
self.vars_to_clear = {
|
||||
var for var in ("RENEWED_DOMAINS", "RENEWED_LINEAGE",)
|
||||
if var not in os.environ)
|
||||
if var not in os.environ
|
||||
}
|
||||
|
||||
def tearDown(self):
|
||||
for var in self.vars_to_clear:
|
||||
|
|
|
|||
|
|
@ -279,9 +279,10 @@ class PluginsRegistryTest(unittest.TestCase):
|
|||
|
||||
def test_prepare_order(self):
|
||||
order: List[str] = []
|
||||
plugins = dict(
|
||||
(c, mock.MagicMock(prepare=functools.partial(order.append, c)))
|
||||
for c in string.ascii_letters)
|
||||
plugins = {
|
||||
c: mock.MagicMock(prepare=functools.partial(order.append, c))
|
||||
for c in string.ascii_letters
|
||||
}
|
||||
reg = self._create_new_registry(plugins)
|
||||
reg.prepare()
|
||||
# order of prepare calls must be sorted to prevent deadlock
|
||||
|
|
|
|||
|
|
@ -493,7 +493,7 @@ def main():
|
|||
|
||||
# print and save summary results
|
||||
results_file = open(log_dir+'/results', 'w')
|
||||
outputs = [outq for outq in iter(outqueue.get, SENTINEL)]
|
||||
outputs = list(iter(outqueue.get, SENTINEL))
|
||||
outputs.sort(key=lambda x: x[0])
|
||||
failed = False
|
||||
results_msg = ""
|
||||
|
|
|
|||
Loading…
Reference in a new issue