Skip to content

Commit b5d2806

Browse files
committed
Update code standards to prohibit inline imports and ensure all imports are at the top of the file
1 parent b7cffe8 commit b5d2806

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

‎.github/skills/code-standards/SKILL.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ description: NetAlertX coding standards and conventions. Use this when writing c
2323
- use environment variables for runtime paths, never hardcode paths or use relative paths
2424
- follow existing code style and structure, and ensure backward compatibility with existing installations when submitting PRs
2525
- all code needs to be scalable to handle large networks with thousands of devices (10k+) without performance degradation
26+
- no inline imports, all imports must be at the top of the file
2627

2728

2829
## File Length

‎test/plugins/test_sync_protocol.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,8 @@ def _parse_sync_payload(file_path: str) -> list:
493493
Returns the list of device dicts on success, or raises nothing on invalid
494494
input — callers should catch JSONDecodeError / KeyError and skip the file.
495495
"""
496-
import json as _json
497496
with open(file_path, "r") as f:
498-
data = _json.load(f)
497+
data = json.load(f)
499498
return data["data"]
500499

501500

@@ -509,7 +508,6 @@ class TestMode3JsonSkip:
509508
"""
510509

511510
def test_valid_sync_payload_is_parsed(self, tmp_path):
512-
import json
513511
payload = {"data": [{"devMac": "aa:bb:cc:dd:ee:01", "devName": "TestDevice"}]}
514512
f = tmp_path / "last_result.ARPSCAN.decoded.Node1.1.log"
515513
f.write_text(json.dumps(payload))
@@ -526,7 +524,6 @@ def test_pipe_delimited_file_raises_json_error(self, tmp_path):
526524

527525
def test_json_without_data_key_raises_key_error(self, tmp_path):
528526
"""JSON that lacks the 'data' key must raise KeyError so callers can skip it."""
529-
import json
530527
f = tmp_path / "last_result.UNKNOWN.log"
531528
f.write_text(json.dumps({"result": []}))
532529
with pytest.raises(KeyError):

0 commit comments

Comments
 (0)