mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
fix: repair imports lost in the 3.1 rebase and meet the new lint baseline
The rebase onto upstream 3.1 (mypy + ruff I001/F401 waves) left the tree short of the newly enforced baselines in three ways: * contextlib / UbridgeError imports dropped as false duplicates during conflict resolution left NameErrors in iou_vm and qemu_vm (F821); the Dynamips router grabbed the compute-level NIOTAP instead of the hypervisor one, breaking TAP anchoring (test failure). * unused imports (KERNEL_UNSUPPORTED_FILTERS, UbridgeError, List) and unsorted blocks left behind where the stack's later commits moved the last usage elsewhere — ruff I001/F401/RUF022 now enforce these. * mypy, now baseline-free: cache dict annotations in tc_probe, the locators candidate list, the resolved-params None branch in the MCP runner, and validate_bpf_syntax keeps the upstream Dict[str, Any] return (the strict Optional[str] was wrong for the "valid" bool entry). The e2e raw-frame probe resolves its compiler via shutil.which (S607) and zips with strict= (B905); the remaining subprocess call is S603 by nature and gets a per-file ignore like other test files. ruff check/format clean, mypy at upstream parity (no new errors), full unit suite 2167 passed.
This commit is contained in:
35 files changed
+165
-136
No files matched your search
@@ -903,7 +903,9 @@ class DockerDaemon:
|
||||
)
|
||||
response = conn.getresponse()
|
||||
payload = response.read()
|
||||
assert response.status == 200, f"docker cp into {container_id[:12]} -> HTTP {response.status}: {payload[:300]!r}"
|
||||
assert response.status == 200, (
|
||||
f"docker cp into {container_id[:12]} -> HTTP {response.status}: {payload[:300]!r}"
|
||||
)
|
||||
except (OSError, http.client.HTTPException) as e:
|
||||
raise AssertionError(f"docker cp into {container_id[:12]} failed: {e}") from None
|
||||
finally:
|
||||
|
||||
@@ -47,6 +47,7 @@ The negative control for the old behaviour is the uBridge suite's
|
||||
import functools
|
||||
import io
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tarfile
|
||||
import tempfile
|
||||
@@ -246,9 +247,12 @@ def _llprobe():
|
||||
binary = os.path.join(directory, "llprobe")
|
||||
with open(source, "w") as f:
|
||||
f.write(_LLPROBE_C)
|
||||
cc = shutil.which("cc")
|
||||
if cc is None:
|
||||
pytest.skip("cannot build the raw-frame probe (no C compiler found)")
|
||||
try:
|
||||
subprocess.run(["cc", "-static", "-O2", "-o", binary, source], check=True, capture_output=True)
|
||||
except (FileNotFoundError, subprocess.CalledProcessError) as e:
|
||||
subprocess.run([cc, "-static", "-O2", "-o", binary, source], check=True, capture_output=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
pytest.skip(f"cannot build the raw-frame probe (cc -static): {e}")
|
||||
return binary
|
||||
|
||||
@@ -270,9 +274,7 @@ def _upload_probe(daemon, *container_ids):
|
||||
|
||||
def _recv_counts(daemon, container_id, window, macs):
|
||||
"""Run the receiver to completion and parse its "<mac>=<count>" lines."""
|
||||
code, output = daemon.exec(
|
||||
container_id, ["/tmp/llprobe", "recv", "eth0", str(window), *macs], timeout=window + 30
|
||||
)
|
||||
code, output = daemon.exec(container_id, ["/tmp/llprobe", "recv", "eth0", str(window), *macs], timeout=window + 30)
|
||||
assert code == 0, output
|
||||
return {line.split("=")[0]: int(line.split("=")[1]) for line in output.strip().splitlines() if "=" in line}
|
||||
|
||||
@@ -316,7 +318,7 @@ def test_docker_link_local_frames():
|
||||
print(".. starting containers")
|
||||
for node in nodes:
|
||||
compute.call("POST", f"/projects/{pid}/nodes/{node['node_id']}/start")
|
||||
for node, address in zip(nodes, (R1_IP, R2_IP)):
|
||||
for node, address in zip(nodes, (R1_IP, R2_IP), strict=True):
|
||||
harness.docker_wait_address(daemon, node["container_id"], address)
|
||||
|
||||
a1 = harness.docker_anchor_name(n1["node_id"], *ETH)
|
||||
|
||||
Reference in new issue
Block a user