From c953e5784d018dcca21a3d80595ac80e61b27fad Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Fri, 22 Dec 2023 07:21:04 -0800 Subject: [PATCH] Fixed C401 (unnecessary-generator-set): Unnecessary generator (rewrite as a `set` comprehension) --- management/dns_update.py | 4 ++-- management/mail_log.py | 2 +- management/status_checks.py | 2 +- management/utils.py | 4 ++-- management/web_update.py | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/management/dns_update.py b/management/dns_update.py index eee99dc3..96cffbae 100755 --- a/management/dns_update.py +++ b/management/dns_update.py @@ -361,8 +361,8 @@ def build_zone(domain, domain_properties, additional_records, env, is_zone=True) # non-mail domain and also may include qnames from custom DNS records. # Do this once at the end of generating a zone. if is_zone: - qnames_with_a = set(qname for (qname, rtype, value, explanation) in records if rtype in {"A", "AAAA"}) - qnames_with_mx = set(qname for (qname, rtype, value, explanation) in records if rtype == "MX") + qnames_with_a = {qname for (qname, rtype, value, explanation) in records if rtype in {"A", "AAAA"}} + qnames_with_mx = {qname for (qname, rtype, value, explanation) in records if rtype == "MX"} for qname in qnames_with_a - qnames_with_mx: # Mark this domain as not sending mail with hard-fail SPF and DMARC records. d = (qname+"." if qname else "") + domain diff --git a/management/mail_log.py b/management/mail_log.py index bb862395..ae718e55 100755 --- a/management/mail_log.py +++ b/management/mail_log.py @@ -116,7 +116,7 @@ def scan_mail_log(env): try: import mailconfig collector["known_addresses"] = (set(mailconfig.get_mail_users(env)) | - set(alias[0] for alias in mailconfig.get_mail_aliases(env))) + {alias[0] for alias in mailconfig.get_mail_aliases(env)}) except ImportError: pass diff --git a/management/status_checks.py b/management/status_checks.py index cc9fd7d4..ac4f3021 100755 --- a/management/status_checks.py +++ b/management/status_checks.py @@ -624,7 +624,7 @@ def check_dnssec(domain, env, output, dns_zonefiles, is_checking_primary=False): # # But it may not be preferred. Only algorithm 13 is preferred. Warn if any of the # matched zones uses a different algorithm. - if set(r[1] for r in matched_ds) == { '13' } and set(r[2] for r in matched_ds) <= { '2', '4' }: # all are alg 13 and digest type 2 or 4 + if {r[1] for r in matched_ds} == { '13' } and {r[2] for r in matched_ds} <= { '2', '4' }: # all are alg 13 and digest type 2 or 4 output.print_ok("DNSSEC 'DS' record is set correctly at registrar.") return elif len([r for r in matched_ds if r[1] == '13' and r[2] in { '2', '4' }]) > 0: # some but not all are alg 13 diff --git a/management/utils.py b/management/utils.py index 0cfce602..982c8c8a 100644 --- a/management/utils.py +++ b/management/utils.py @@ -99,10 +99,10 @@ def sort_domains(domain_names, env): def sort_email_addresses(email_addresses, env): email_addresses = set(email_addresses) - domains = set(email.split("@", 1)[1] for email in email_addresses if "@" in email) + domains = {email.split("@", 1)[1] for email in email_addresses if "@" in email} ret = [] for domain in sort_domains(domains, env): - domain_emails = set(email for email in email_addresses if email.endswith("@" + domain)) + domain_emails = {email for email in email_addresses if email.endswith("@" + domain)} ret.extend(sorted(domain_emails)) email_addresses -= domain_emails ret.extend(sorted(email_addresses)) # whatever is left diff --git a/management/web_update.py b/management/web_update.py index 498f87c5..6747a5b8 100644 --- a/management/web_update.py +++ b/management/web_update.py @@ -22,17 +22,17 @@ def get_web_domains(env, include_www_redirects=True, include_auto=True, exclude_ # Add 'www.' subdomains that we want to provide default redirects # to the main domain for. We'll add 'www.' to any DNS zones, i.e. # the topmost of each domain we serve. - domains |= set('www.' + zone for zone, zonefile in get_dns_zones(env)) + domains |= {'www.' + zone for zone, zonefile in get_dns_zones(env)} if include_auto: # Add Autoconfiguration domains for domains that there are user accounts at: # 'autoconfig.' for Mozilla Thunderbird auto setup. # 'autodiscover.' for ActiveSync autodiscovery (Z-Push). - domains |= set('autoconfig.' + maildomain for maildomain in get_mail_domains(env, users_only=True)) - domains |= set('autodiscover.' + maildomain for maildomain in get_mail_domains(env, users_only=True)) + domains |= {'autoconfig.' + maildomain for maildomain in get_mail_domains(env, users_only=True)} + domains |= {'autodiscover.' + maildomain for maildomain in get_mail_domains(env, users_only=True)} # 'mta-sts.' for MTA-STS support for all domains that have email addresses. - domains |= set('mta-sts.' + maildomain for maildomain in get_mail_domains(env)) + domains |= {'mta-sts.' + maildomain for maildomain in get_mail_domains(env)} if exclude_dns_elsewhere: # ...Unless the domain has an A/AAAA record that maps it to a different