Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/certbot/certbot.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMads Jensen <mje@inducks.org>2022-02-15 01:54:03 +0300
committerGitHub <noreply@github.com>2022-02-15 01:54:03 +0300
commit6f85eb928c2c6f670b169ec4f86c296f6d15ba71 (patch)
tree2d62ccd7ff12392137db99f8c6b5bdcfd48eacee
parenta1b2e973c00a92efa8de1687e1b3c33d4ed76e70 (diff)
Use literals wherever possible. (#9194)
* Use literals wherever possible. These were found with flake8-comprehensions.
-rw-r--r--acme/acme/messages.py10
-rw-r--r--certbot-compatibility-test/certbot_compatibility_test/configurators/nginx/common.py2
-rw-r--r--certbot-nginx/certbot_nginx/_internal/constants.py10
-rw-r--r--certbot/certbot/_internal/auth_handler.py2
-rw-r--r--certbot/certbot/_internal/client.py2
-rw-r--r--certbot/certbot/_internal/constants.py12
-rw-r--r--certbot/certbot/_internal/plugins/manual.py10
-rw-r--r--certbot/certbot/_internal/storage.py7
-rw-r--r--certbot/tests/hook_test.py5
-rw-r--r--certbot/tests/plugins/disco_test.py7
-rw-r--r--letstest/letstest/multitester.py2
11 files changed, 37 insertions, 32 deletions
diff --git a/acme/acme/messages.py b/acme/acme/messages.py
index c02a600da..c9704d537 100644
--- a/acme/acme/messages.py
+++ b/acme/acme/messages.py
@@ -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:
diff --git a/certbot-compatibility-test/certbot_compatibility_test/configurators/nginx/common.py b/certbot-compatibility-test/certbot_compatibility_test/configurators/nginx/common.py
index 4a103194f..1282923bf 100644
--- a/certbot-compatibility-test/certbot_compatibility_test/configurators/nginx/common.py
+++ b/certbot-compatibility-test/certbot_compatibility_test/configurators/nginx/common.py
@@ -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
diff --git a/certbot-nginx/certbot_nginx/_internal/constants.py b/certbot-nginx/certbot_nginx/_internal/constants.py
index aa242903e..295679e2c 100644
--- a/certbot-nginx/certbot_nginx/_internal/constants.py
+++ b/certbot-nginx/certbot_nginx/_internal/constants.py
@@ -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."""
diff --git a/certbot/certbot/_internal/auth_handler.py b/certbot/certbot/_internal/auth_handler.py
index 08dc8be35..16b8dfdbe 100644
--- a/certbot/certbot/_internal/auth_handler.py
+++ b/certbot/certbot/_internal/auth_handler.py
@@ -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])
diff --git a/certbot/certbot/_internal/client.py b/certbot/certbot/_internal/client.py
index bc9cf6937..9688918cd 100644
--- a/certbot/certbot/_internal/client.py
+++ b/certbot/certbot/_internal/client.py
@@ -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
diff --git a/certbot/certbot/_internal/constants.py b/certbot/certbot/_internal/constants.py
index 18160d47e..3867d777c 100644
--- a/certbot/certbot/_internal/constants.py
+++ b/certbot/certbot/_internal/constants.py
@@ -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"
diff --git a/certbot/certbot/_internal/plugins/manual.py b/certbot/certbot/_internal/plugins/manual.py
index 6c69b7e5b..a5c9559e4 100644
--- a/certbot/certbot/_internal/plugins/manual.py
+++ b/certbot/certbot/_internal/plugins/manual.py
@@ -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:
diff --git a/certbot/certbot/_internal/storage.py b/certbot/certbot/_internal/storage.py
index 2b4f44fd1..5dd3e565b 100644
--- a/certbot/certbot/_internal/storage.py
+++ b/certbot/certbot/_internal/storage.py
@@ -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.
diff --git a/certbot/tests/hook_test.py b/certbot/tests/hook_test.py
index 3bfca4e4a..fad18dc9f 100644
--- a/certbot/tests/hook_test.py
+++ b/certbot/tests/hook_test.py
@@ -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:
diff --git a/certbot/tests/plugins/disco_test.py b/certbot/tests/plugins/disco_test.py
index 833acdfb0..7c2dda0da 100644
--- a/certbot/tests/plugins/disco_test.py
+++ b/certbot/tests/plugins/disco_test.py
@@ -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
diff --git a/letstest/letstest/multitester.py b/letstest/letstest/multitester.py
index a56bf0f37..437f34dc9 100644
--- a/letstest/letstest/multitester.py
+++ b/letstest/letstest/multitester.py
@@ -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 = ""