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

@@ -1,15 +1,17 @@
import shutil
import sys
from pathlib import Path
import shutil
import pytest
from unittest.mock import MagicMock, patch
import pytest
from git.exc import InvalidGitRepositoryError
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
from src.services.git_service import GitService
from src.core.superset_client import SupersetClient
from src.core.config_models import Environment
from src.core.superset_client import SupersetClient
from src.services.git_service import GitService
# [DEF:test_git_service_get_repo_path_guard:Function]
# @RELATION: BINDS_TO -> UnknownModule

View File

@@ -9,8 +9,8 @@ import asyncio
import sys
from pathlib import Path
from fastapi import HTTPException
import pytest
from fastapi import HTTPException
sys.path.insert(0, str(Path(__file__).parent.parent.parent))

View File

@@ -4,21 +4,21 @@
# @LAYER: Domain
# @RELATION: VERIFIES ->[src.core.mapping_service.IdMappingService]
#
import sys
from datetime import UTC, datetime
from pathlib import Path
import pytest
from datetime import datetime, timezone
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import sys
import os
from pathlib import Path
# Add backend directory to sys.path so 'src' can be resolved
backend_dir = str(Path(__file__).parent.parent.parent.resolve())
if backend_dir not in sys.path:
sys.path.insert(0, backend_dir)
from src.models.mapping import Base, ResourceMapping, ResourceType
from src.core.mapping_service import IdMappingService
from src.models.mapping import Base, ResourceMapping, ResourceType
@pytest.fixture
@@ -80,7 +80,7 @@ def test_get_remote_id_returns_integer(db_session):
uuid="uuid-1",
remote_integer_id="99",
resource_name="Test DS",
last_synced_at=datetime.now(timezone.utc),
last_synced_at=datetime.now(UTC),
)
db_session.add(mapping)
db_session.commit()

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 (