From b5d280644e06912a23c2339bd99bfa14acf243f2 Mon Sep 17 00:00:00 2001 From: "Jokob @NetAlertX" <96159884+jokob-sk@users.noreply.github.com> Date: Sun, 24 May 2026 02:21:56 +0000 Subject: [PATCH] Update code standards to prohibit inline imports and ensure all imports are at the top of the file --- .github/skills/code-standards/SKILL.md | 1 + test/plugins/test_sync_protocol.py | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/skills/code-standards/SKILL.md b/.github/skills/code-standards/SKILL.md index 6d522d39..83c52d0a 100644 --- a/.github/skills/code-standards/SKILL.md +++ b/.github/skills/code-standards/SKILL.md @@ -23,6 +23,7 @@ description: NetAlertX coding standards and conventions. Use this when writing c - use environment variables for runtime paths, never hardcode paths or use relative paths - follow existing code style and structure, and ensure backward compatibility with existing installations when submitting PRs - all code needs to be scalable to handle large networks with thousands of devices (10k+) without performance degradation +- no inline imports, all imports must be at the top of the file ## File Length diff --git a/test/plugins/test_sync_protocol.py b/test/plugins/test_sync_protocol.py index 5a228a9c..fc0a7bdb 100644 --- a/test/plugins/test_sync_protocol.py +++ b/test/plugins/test_sync_protocol.py @@ -493,9 +493,8 @@ def _parse_sync_payload(file_path: str) -> list: Returns the list of device dicts on success, or raises nothing on invalid input — callers should catch JSONDecodeError / KeyError and skip the file. """ - import json as _json with open(file_path, "r") as f: - data = _json.load(f) + data = json.load(f) return data["data"] @@ -509,7 +508,6 @@ class TestMode3JsonSkip: """ def test_valid_sync_payload_is_parsed(self, tmp_path): - import json payload = {"data": [{"devMac": "aa:bb:cc:dd:ee:01", "devName": "TestDevice"}]} f = tmp_path / "last_result.ARPSCAN.decoded.Node1.1.log" f.write_text(json.dumps(payload)) @@ -526,7 +524,6 @@ class TestMode3JsonSkip: def test_json_without_data_key_raises_key_error(self, tmp_path): """JSON that lacks the 'data' key must raise KeyError so callers can skip it.""" - import json f = tmp_path / "last_result.UNKNOWN.log" f.write_text(json.dumps({"result": []})) with pytest.raises(KeyError):