Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/ci/prek/prevent_deprecated_sqlalchemy_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
console = Console(color_system="standard", width=200)


def check_session_query(mod: ast.Module) -> int:
def check_session_query(mod: ast.Module, file_path: str) -> int:
errors = False
for node in ast.walk(mod):
if isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute):
Expand All @@ -36,7 +36,7 @@ def check_session_query(mod: ast.Module) -> int:
and node.func.value.id == "session"
):
console.print(
f"\nUse of legacy `session.query` detected on line {node.lineno}. "
f"\nUse of legacy `session.query` detected on line {node.lineno} in {file_path} "
f"\nSQLAlchemy 2.0 deprecates the `Query` object"
f"use the `select()` construct instead."
)
Expand All @@ -48,7 +48,7 @@ def main():
for file in sys.argv[1:]:
file_path = Path(file)
ast_module = ast.parse(file_path.read_text(encoding="utf-8"), file)
errors = check_session_query(ast_module)
errors = check_session_query(ast_module, file_path)
return 1 if errors else 0


Expand Down
Loading