Skip to content

Commit 98c86a5

Browse files
Add list parsing key-display import boundary guard
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 8b58872 commit 98c86a5

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ This runs lint, format checks, compile checks, tests, and package build.
170170
- `tests/test_list_parsing_helper_usage.py` (list parsing shared helper usage centralization),
171171
- `tests/test_list_parsing_helpers_import_boundary.py` (list parsing helper import boundary enforcement),
172172
- `tests/test_list_parsing_key_display_helper_usage.py` (list parsing safe key-display helper usage enforcement),
173+
- `tests/test_list_parsing_key_display_import_boundary.py` (list parsing safe key-display helper import boundary enforcement),
173174
- `tests/test_makefile_quality_targets.py` (Makefile quality-gate target enforcement),
174175
- `tests/test_manager_helper_import_boundary.py` (manager helper-import boundary enforcement for low-level parse modules),
175176
- `tests/test_manager_model_dump_usage.py` (manager serialization centralization),

tests/test_architecture_marker_usage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@
127127
"tests/test_job_request_helper_usage.py",
128128
"tests/test_job_start_payload_helper_usage.py",
129129
"tests/test_job_query_params_helper_usage.py",
130+
"tests/test_list_parsing_helper_usage.py",
130131
"tests/test_list_parsing_helpers_import_boundary.py",
131132
"tests/test_list_parsing_key_display_helper_usage.py",
132-
"tests/test_list_parsing_helper_usage.py",
133+
"tests/test_list_parsing_key_display_import_boundary.py",
133134
"tests/test_job_wait_helper_boundary.py",
134135
"tests/test_job_wait_helper_usage.py",
135136
"tests/test_example_sync_async_parity.py",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import ast
2+
from pathlib import Path
3+
4+
import pytest
5+
6+
pytestmark = pytest.mark.architecture
7+
8+
LIST_PARSING_MODULE = Path("hyperbrowser/client/managers/list_parsing_utils.py")
9+
10+
11+
def _imports_safe_key_display_for_error(module_text: str) -> bool:
12+
module_ast = ast.parse(module_text)
13+
for node in module_ast.body:
14+
if not isinstance(node, ast.ImportFrom):
15+
continue
16+
if node.module != "hyperbrowser.mapping_utils":
17+
continue
18+
if any(alias.name == "safe_key_display_for_error" for alias in node.names):
19+
return True
20+
return False
21+
22+
23+
def test_list_parsing_safe_key_display_helper_is_imported_from_mapping_utils():
24+
module_text = LIST_PARSING_MODULE.read_text(encoding="utf-8")
25+
assert _imports_safe_key_display_for_error(module_text)

0 commit comments

Comments
 (0)