File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from pathlib import Path
2+ import ast
23
34import pytest
45
@@ -54,3 +55,25 @@ def test_key_formatting_helper_usage_is_centralized():
5455 helper_usage_files .add (relative_path )
5556
5657 assert helper_usage_files == ALLOWED_KEY_FORMAT_CALL_FILES
58+
59+
60+ def test_key_formatting_helper_calls_use_explicit_max_length_keyword ():
61+ missing_max_length_keyword_calls : list [str ] = []
62+
63+ for path in _python_files ():
64+ relative_path = path .relative_to (HYPERBROWSER_ROOT )
65+ if relative_path not in ALLOWED_KEY_FORMAT_CALL_FILES :
66+ continue
67+ module = read_module_ast (path )
68+ for node in ast .walk (module ):
69+ if not isinstance (node , ast .Call ):
70+ continue
71+ if not isinstance (node .func , ast .Name ):
72+ continue
73+ if node .func .id != "format_string_key_for_error" :
74+ continue
75+ if any (keyword .arg == "max_length" for keyword in node .keywords ):
76+ continue
77+ missing_max_length_keyword_calls .append (f"{ relative_path } :{ node .lineno } " )
78+
79+ assert missing_max_length_keyword_calls == []
You can’t perform that action at this time.
0 commit comments