From 50f6dcdc756fd11d07baa4d9f6ae7333d7a6ab4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Bal=C3=A1=C5=BEik?= Date: Wed, 28 Jan 2026 15:12:45 +0100 Subject: [PATCH] Fix pylint's 'invalid-name' errors Where possible comply with the naming rules. Add exceptions for the function names used in KASP tests. (cherry picked from commit 50ed74197cee16ff9df55175a251c341a191b0b3) --- .gitlab-ci.yml | 4 ++-- bin/tests/Makefile.am | 2 +- ...convert-trs-to-junit.py => convert_trs_to_junit.py} | 0 ...convert-junit-to-trs.py => convert_junit_to_trs.py} | 2 +- bin/tests/system/custom-test-driver | 2 +- bin/tests/system/isctest/kasp.py | 10 +++++----- .../{tests_cve-2023-3341.py => tests_cve_2023_3341.py} | 0 bin/tests/system/statschannel/generic.py | 8 ++++---- bin/tests/system/statschannel/tests_json.py | 6 +++--- bin/tests/system/statschannel/tests_xml.py | 6 +++--- bin/tests/system/xferquota/setup.py | 6 +++--- pyproject.toml | 7 ++++++- 12 files changed, 29 insertions(+), 24 deletions(-) rename bin/tests/{convert-trs-to-junit.py => convert_trs_to_junit.py} (100%) rename bin/tests/system/{convert-junit-to-trs.py => convert_junit_to_trs.py} (96%) rename bin/tests/system/rndc/{tests_cve-2023-3341.py => tests_cve_2023_3341.py} (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d97bc7c5f4..95b87b0233 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -600,7 +600,7 @@ stages: - cd "$CI_PROJECT_DIR" - *find_python - > - "$PYTHON" bin/tests/convert-trs-to-junit.py . > "$CI_PROJECT_DIR"/junit_system.xml + "$PYTHON" bin/tests/convert_trs_to_junit.py . > "$CI_PROJECT_DIR"/junit_system.xml - *git_clone_bind9-qa - > "$PYTHON" "$CI_PROJECT_DIR"/bind9-qa/ci/postprocess_junit_files.py "$CI_PROJECT_DIR"/junit_system.xml --output "$CI_PROJECT_DIR"/junit.xml @@ -632,7 +632,7 @@ stages: - *find_python - *git_clone_bind9-qa - > - "$PYTHON" "$CI_PROJECT_DIR"/bin/tests/convert-trs-to-junit.py . > "$CI_PROJECT_DIR"/junit_unit.xml + "$PYTHON" "$CI_PROJECT_DIR"/bin/tests/convert_trs_to_junit.py . > "$CI_PROJECT_DIR"/junit_unit.xml - > "$PYTHON" "$CI_PROJECT_DIR"/bind9-qa/ci/postprocess_junit_files.py "$CI_PROJECT_DIR"/junit_unit.xml --output "$CI_PROJECT_DIR"/junit.xml - (exit $RET) diff --git a/bin/tests/Makefile.am b/bin/tests/Makefile.am index 56e81b118a..2dd2067ba6 100644 --- a/bin/tests/Makefile.am +++ b/bin/tests/Makefile.am @@ -1,6 +1,6 @@ include $(top_srcdir)/Makefile.top -EXTRA_DIST = convert-trs-to-junit.py +EXTRA_DIST = convert_trs_to_junit.py SUBDIRS = system diff --git a/bin/tests/convert-trs-to-junit.py b/bin/tests/convert_trs_to_junit.py similarity index 100% rename from bin/tests/convert-trs-to-junit.py rename to bin/tests/convert_trs_to_junit.py diff --git a/bin/tests/system/convert-junit-to-trs.py b/bin/tests/system/convert_junit_to_trs.py similarity index 96% rename from bin/tests/system/convert-junit-to-trs.py rename to bin/tests/system/convert_junit_to_trs.py index 3726e19fb5..83cf630274 100755 --- a/bin/tests/system/convert-junit-to-trs.py +++ b/bin/tests/system/convert_junit_to_trs.py @@ -17,7 +17,7 @@ def junit_to_trs(junit_xml): testcases = root.findall(".//testcase") if len(testcases) < 1: - print(":test-result: ERROR convert-junit-to-trs.py") + print(":test-result: ERROR convert_junit_to_trs.py") return 99 has_fail = False diff --git a/bin/tests/system/custom-test-driver b/bin/tests/system/custom-test-driver index 278cb377e2..a2f76910b1 100755 --- a/bin/tests/system/custom-test-driver +++ b/bin/tests/system/custom-test-driver @@ -146,7 +146,7 @@ else fi # Run junit to trs converter script. -./convert-junit-to-trs.py $junit_file >$trs_file +./convert_junit_to_trs.py $junit_file >$trs_file estatus=$? if test $enable_hard_errors = no && test $estatus -eq 99; then diff --git a/bin/tests/system/isctest/kasp.py b/bin/tests/system/isctest/kasp.py index 950a8d994f..18682f3bd8 100644 --- a/bin/tests/system/isctest/kasp.py +++ b/bin/tests/system/isctest/kasp.py @@ -84,24 +84,24 @@ def Iret(config, zsk=True, ksk=False, rollover=True, smooth=True): sign_delay = config["signatures-validity"] - config["signatures-refresh"] safety_interval = config["retire-safety"] - iretKSK = timedelta(0) + iret_ksk = timedelta(0) if ksk: # KSK: Double-KSK Method: Iret = DprpP + TTLds - iretKSK = ( + iret_ksk = ( config["parent-propagation-delay"] + config["ds-ttl"] + safety_interval ) - iretZSK = timedelta(0) + iret_zsk = timedelta(0) if zsk: # ZSK: Pre-Publication Method: Iret = Dsgn + Dprp + TTLsig - iretZSK = ( + iret_zsk = ( sign_delay + config["zone-propagation-delay"] + config["max-zone-ttl"] + safety_interval ) - return max(iretKSK, iretZSK) + return max(iret_ksk, iret_zsk) @total_ordering diff --git a/bin/tests/system/rndc/tests_cve-2023-3341.py b/bin/tests/system/rndc/tests_cve_2023_3341.py similarity index 100% rename from bin/tests/system/rndc/tests_cve-2023-3341.py rename to bin/tests/system/rndc/tests_cve_2023_3341.py diff --git a/bin/tests/system/statschannel/generic.py b/bin/tests/system/statschannel/generic.py index e77f3fc37f..09a374e120 100644 --- a/bin/tests/system/statschannel/generic.py +++ b/bin/tests/system/statschannel/generic.py @@ -21,7 +21,7 @@ import dns.rcode import isctest # ISO datetime format without msec -fmt = "%Y-%m-%dT%H:%M:%SZ" +FMT = "%Y-%m-%dT%H:%M:%SZ" # The constants were taken from BIND 9 source code (lib/dns/zone.c) max_refresh = timedelta(seconds=2419200) # 4 weeks @@ -29,7 +29,7 @@ max_expires = timedelta(seconds=14515200) # 24 weeks dayzero = datetime.utcfromtimestamp(0).replace(microsecond=0) # Wait for the secondary zone files to appear to extract their mtime -max_secondary_zone_waittime_sec = 5 +MAX_SECONDARY_ZONE_WAITTIME_SEC = 5 # Generic helper functions @@ -45,7 +45,7 @@ def check_refresh(refresh, min_time, max_time): def check_loaded(loaded, expected, now): # Sanity check the zone timers values - assert (loaded - expected).total_seconds() < max_secondary_zone_waittime_sec + assert (loaded - expected).total_seconds() < MAX_SECONDARY_ZONE_WAITTIME_SEC assert loaded <= now @@ -97,7 +97,7 @@ def test_zone_timers_secondary(fetch_zones, load_timers, **kwargs): zonedir = kwargs["zonedir"] # If any one of the zone files isn't ready, then retry until timeout. - tries = max_secondary_zone_waittime_sec + tries = MAX_SECONDARY_ZONE_WAITTIME_SEC while tries >= 0: zones = fetch_zones(statsip, statsport) again = False diff --git a/bin/tests/system/statschannel/tests_json.py b/bin/tests/system/statschannel/tests_json.py index 72a6e41e1b..30348f4e69 100755 --- a/bin/tests/system/statschannel/tests_json.py +++ b/bin/tests/system/statschannel/tests_json.py @@ -67,7 +67,7 @@ def load_timers_json(zone, primary=True): # Check if the primary zone timer exists assert "loaded" in zone - loaded = datetime.strptime(zone["loaded"], generic.fmt) + loaded = datetime.strptime(zone["loaded"], generic.FMT) if primary: # Check if the secondary zone timers does not exist @@ -78,8 +78,8 @@ def load_timers_json(zone, primary=True): else: assert "expires" in zone assert "refresh" in zone - expires = datetime.strptime(zone["expires"], generic.fmt) - refresh = datetime.strptime(zone["refresh"], generic.fmt) + expires = datetime.strptime(zone["expires"], generic.FMT) + refresh = datetime.strptime(zone["refresh"], generic.FMT) return (name, loaded, expires, refresh) diff --git a/bin/tests/system/statschannel/tests_xml.py b/bin/tests/system/statschannel/tests_xml.py index e0c8dd3425..1ceb46f9b4 100755 --- a/bin/tests/system/statschannel/tests_xml.py +++ b/bin/tests/system/statschannel/tests_xml.py @@ -95,7 +95,7 @@ def load_timers_xml(zone, primary=True): loaded_el = zone.find("loaded") assert loaded_el is not None - loaded = datetime.strptime(loaded_el.text, generic.fmt) + loaded = datetime.strptime(loaded_el.text, generic.FMT) expires_el = zone.find("expires") refresh_el = zone.find("refresh") @@ -107,8 +107,8 @@ def load_timers_xml(zone, primary=True): else: assert expires_el is not None assert refresh_el is not None - expires = datetime.strptime(expires_el.text, generic.fmt) - refresh = datetime.strptime(refresh_el.text, generic.fmt) + expires = datetime.strptime(expires_el.text, generic.FMT) + refresh = datetime.strptime(refresh_el.text, generic.FMT) return (name, loaded, expires, refresh) diff --git a/bin/tests/system/xferquota/setup.py b/bin/tests/system/xferquota/setup.py index ec457bf171..bd8f96bc0c 100644 --- a/bin/tests/system/xferquota/setup.py +++ b/bin/tests/system/xferquota/setup.py @@ -15,9 +15,9 @@ # Set up test data for zone transfer quota tests. # -zones = 300 +ZONES = 300 -for z in range(zones): +for z in range(ZONES): zn = f"zone{z:06d}.example" with open(f"ns1/{zn}.db", "w", encoding="utf-8") as f: f.write("""$TTL 300 @@ -35,7 +35,7 @@ xyzzy A 10.0.0.2 with open("ns1/zones.conf", "w", encoding="utf-8") as priconf, open( "ns2/zones.conf", "w", encoding="utf-8" ) as secconf: - for z in range(zones): + for z in range(ZONES): zn = f"zone{z:06d}.example" priconf.write(f'zone "{zn}" {{ type primary; file "{zn}.db"; }};\n') secconf.write( diff --git a/pyproject.toml b/pyproject.toml index 99ce2021e4..9b6d430ec9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,13 +9,18 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. +[tool.pylint.basic] +good-names-rgxs = [ + # Allow names from KASP tests + "I(pub|ret)C?", + "T(act|pub|ret|rem|sbm)N1?", +] [tool.pylint.imports] deprecated-modules = [ "dns.resolver", ] [tool.pylint.messages_control] disable = [ - "C0103", # invalid-name "C0114", # missing-module-docstring "C0115", # missing-class-docstring "C0116", # missing-function-docstring