Forward-port lab3 SQLAlchemy and Alembic foundation
Carry sourcef591fa64e5forward from72a1e57. Preserve lab4 attachment transactions, reconciliation locks, quarantine, and existing schema data through verified legacy adoption. Keep report and evidence work in progress untouched.
This commit is contained in:
@@ -230,6 +230,16 @@ def sql_tables(zone: str, tables: tuple[str, ...]) -> set[str]:
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.Constant) and isinstance(node.value, str):
|
||||
words.update(re.findall(r"\b(?:FROM|JOIN|INTO|UPDATE)\s+(\w+)", node.value))
|
||||
if (
|
||||
isinstance(node, ast.Assign)
|
||||
and any(
|
||||
isinstance(target, ast.Name) and target.id == "__tablename__"
|
||||
for target in node.targets
|
||||
)
|
||||
and isinstance(node.value, ast.Constant)
|
||||
and isinstance(node.value.value, str)
|
||||
):
|
||||
words.add(node.value.value)
|
||||
return words & set(tables)
|
||||
|
||||
|
||||
@@ -250,3 +260,11 @@ def test_messaging_does_not_import_identity_at_all() -> None:
|
||||
for path in modules_under("messaging")
|
||||
}
|
||||
assert not {key: value for key, value in borrowed.items() if value}
|
||||
|
||||
|
||||
def test_sqlalchemy_stays_in_infrastructure_and_asyncpg_is_only_a_driver() -> None:
|
||||
for path in SOURCE.rglob("*.py"):
|
||||
modules = {module.split(".")[0] for module in imports_of(path)}
|
||||
assert "asyncpg" not in modules
|
||||
if "infrastructure" not in path.parts:
|
||||
assert "sqlalchemy" not in modules
|
||||
|
||||
Reference in New Issue
Block a user