chore(lint): apply ruff --fix (4443 auto-fixes)

Auto-fixed categories:
- F401: unused imports removed
- I001: import blocks sorted
- W293: trailing whitespace stripped
- UP035: deprecated typing imports replaced
- SIM: simplify suggestions applied
- ARG: unused args prefixed with underscore
- T201: print statements removed
- F841: unused variables removed
- RUF059: unpacked variables prefixed

Remaining ~1500 unfixable errors (C901, B904, N806, E402) require manual work.

Backend smoke tests: 13/13 passed.
This commit is contained in:
2026-05-14 11:20:17 +03:00
parent a9a5eff518
commit c6189876b3
337 changed files with 4677 additions and 4515 deletions

View File

@@ -4,24 +4,21 @@
# @LAYER: Domain
# @RELATION: VERIFIES -> [src.core.migration_engine:Module]
#
import pytest
import tempfile
import json
import yaml
import zipfile
import sys
import os
import sys
import tempfile
import zipfile
from pathlib import Path
from unittest.mock import MagicMock
import pytest
import yaml
backend_dir = str(Path(__file__).parent.parent.parent.resolve())
if backend_dir not in sys.path:
sys.path.insert(0, backend_dir)
from src.core.migration_engine import MigrationEngine
from src.core.mapping_service import IdMappingService
from src.models.mapping import ResourceType
# --- Fixtures ---
@@ -80,7 +77,7 @@ def test_patch_dashboard_metadata_replaces_chart_ids():
engine._patch_dashboard_metadata(fp, "target-env", source_map)
with open(fp, "r") as f:
with open(fp) as f:
data = yaml.safe_load(f)
result = json.loads(data["json_metadata"])
assert (
@@ -107,7 +104,7 @@ def test_patch_dashboard_metadata_replaces_dataset_ids():
engine._patch_dashboard_metadata(fp, "target-env", source_map)
with open(fp, "r") as f:
with open(fp) as f:
data = yaml.safe_load(f)
result = json.loads(data["json_metadata"])
assert (
@@ -134,7 +131,7 @@ def test_patch_dashboard_metadata_skips_when_no_metadata():
engine._patch_dashboard_metadata(fp, "target-env", {})
with open(fp, "r") as f:
with open(fp) as f:
data = yaml.safe_load(f)
assert "json_metadata" not in data
@@ -162,7 +159,7 @@ def test_patch_dashboard_metadata_handles_missing_targets():
engine._patch_dashboard_metadata(fp, "target-env", source_map)
with open(fp, "r") as f:
with open(fp) as f:
data = yaml.safe_load(f)
result = json.loads(data["json_metadata"])
targets = result["native_filter_configuration"][0]["targets"]
@@ -219,7 +216,7 @@ def test_transform_yaml_replaces_database_uuid():
engine._transform_yaml(fp, {"source-uuid-abc": "target-uuid-xyz"})
with open(fp, "r") as f:
with open(fp) as f:
data = yaml.safe_load(f)
assert data["database_uuid"] == "target-uuid-xyz"
assert data["table_name"] == "my_table"
@@ -243,7 +240,7 @@ def test_transform_yaml_ignores_unmapped_uuid():
engine._transform_yaml(fp, {"other-uuid": "replacement"})
with open(fp, "r") as f:
with open(fp) as f:
data = yaml.safe_load(f)
assert data["database_uuid"] == "unknown-uuid"
@@ -317,12 +314,12 @@ def test_transform_zip_end_to_end():
out_path = Path(out_dir)
# Verify dataset transformation
with open(out_path / "datasets" / "ds.yaml", "r") as f:
with open(out_path / "datasets" / "ds.yaml") as f:
ds_data = yaml.safe_load(f)
assert ds_data["database_uuid"] == "target-db-uuid"
# Verify dashboard patching
with open(out_path / "dashboards" / "db.yaml", "r") as f:
with open(out_path / "dashboards" / "db.yaml") as f:
db_data = yaml.safe_load(f)
meta = json.loads(db_data["json_metadata"])
assert (