Skip to content

Commit 6d4e361

Browse files
Enforce explicit safe-key-display keyword binding
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 8547eda commit 6d4e361

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/test_safe_key_display_helper_usage.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pathlib import Path
2+
import ast
23

34
import pytest
45

@@ -33,3 +34,25 @@ def test_safe_key_display_usage_is_centralized():
3334
violations.append(f"{relative_path}:{line}")
3435

3536
assert violations == []
37+
38+
39+
def test_safe_key_display_calls_use_explicit_key_display_keyword():
40+
missing_keyword_calls: list[str] = []
41+
42+
for path in _python_files():
43+
relative_path = path.relative_to(HYPERBROWSER_ROOT)
44+
if relative_path not in ALLOWED_SAFE_KEY_DISPLAY_CALL_FILES:
45+
continue
46+
module = read_module_ast(path)
47+
for node in ast.walk(module):
48+
if not isinstance(node, ast.Call):
49+
continue
50+
if not isinstance(node.func, ast.Name):
51+
continue
52+
if node.func.id != "safe_key_display_for_error":
53+
continue
54+
if any(keyword.arg == "key_display" for keyword in node.keywords):
55+
continue
56+
missing_keyword_calls.append(f"{relative_path}:{node.lineno}")
57+
58+
assert missing_keyword_calls == []

0 commit comments

Comments
 (0)