lint: remove unused variables in module_utils and tests

https://chatgpt.com/share/6942c80f-c904-800f-8793-f804da1aa891
This commit is contained in:
2025-12-17 16:10:58 +01:00
parent 9f76946735
commit ee3e86684a
7 changed files with 1 additions and 12 deletions

View File

@@ -175,7 +175,6 @@ try:
def play_infinito_intro_sound(cls) -> None:
build_time = 10.0
celebr_time = 12.0
breakdown_time = 10.0
overlap = 3.0
bass_seg = 0.125

View File

@@ -45,7 +45,6 @@ class ValidDeployId:
Manually parse INI inventory for sections and host lists.
Returns True if app_id matches a section name or a host in a section.
"""
present = False
with open(inventory_path, 'r', encoding='utf-8') as f:
current_section = None
for raw in f:

View File

@@ -175,7 +175,6 @@ try:
def play_infinito_intro_sound(cls) -> None:
build_time = 10.0
celebr_time = 12.0
breakdown_time = 10.0
overlap = 3.0
bass_seg = 0.125

View File

@@ -45,7 +45,6 @@ class ValidDeployId:
Manually parse INI inventory for sections and host lists.
Returns True if app_id matches a section name or a host in a section.
"""
present = False
with open(inventory_path, 'r', encoding='utf-8') as f:
current_section = None
for raw in f:

View File

@@ -24,7 +24,7 @@ class TestDockerRoleServicesConfiguration(unittest.TestCase):
try:
config = yaml.safe_load(cfg_file.read_text("utf-8")) or {}
main_file = role_path / "vars" / "main.yml"
main = yaml.safe_load(main_file.read_text("utf-8")) or {}
yaml.safe_load(main_file.read_text("utf-8")) or {}
except yaml.YAMLError as e:
errors.append(f"{role_path.name}: YAML parse error: {e}")
continue

View File

@@ -247,16 +247,12 @@ class TestUnnecessaryRoleDependencies(unittest.TestCase):
# --- 2) Task-level analysis
any_usage = False
any_bad_order = False
any_include_somewhere = False
for path, text in task_texts:
if not text:
continue
include_off = first_include_offset_for_role(text, producer)
if include_off is not None:
any_include_somewhere = True
var_use_off = first_var_use_offset_in_text(text, provided_vars)
notify_offs = find_notify_offsets_for_handlers(text, provider_handlers)
@@ -277,14 +273,12 @@ class TestUnnecessaryRoleDependencies(unittest.TestCase):
if not any_bad_order:
if not any_usage:
reason = "no variable/handler usage detected in consumer"
suggest = "remove from meta/dependencies; include only where needed (optionally guarded)."
warnings.append(
f"[{consumer}] meta dependency on '{producer}' appears unnecessary: {reason}."
)
else:
# Usage exists but guarded by include in each file
reason = "all usages occur after include/import in the same task file"
suggest = "remove from meta/dependencies; keep the explicit include/import (guard with run_once_* if global)."
warnings.append(
f"[{consumer}] meta dependency on '{producer}' appears unnecessary: {reason}."
)

View File

@@ -20,7 +20,6 @@ class TestDomainMappings(unittest.TestCase):
def test_empty_domains_cfg(self):
apps = {'web-app-desktop': {'domains': {}}}
default = 'desktop.example.com'
expected = []
result = self.filter.domain_mappings(apps, self.primary, True)
self.assertEqual(result, expected)