potiuk commented on code in PR #60012:
URL: https://github.com/apache/airflow/pull/60012#discussion_r2659120450
##########
dev/check_no_orm_in_migrations.py:
##########
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+"""
+Pre-commit hook: Ensure no Alembic migration script imports ORM models.
+"""
+import sys
+import re
+from pathlib import Path
+
+MIGRATIONS_DIRS = [
+ Path("airflow-core/src/airflow/migrations/versions"),
+]
+ORM_IMPORT_PATTERNS = [
+ re.compile(r"from +airflow\\.models"),
+ re.compile(r"import +airflow\\.models"),
+ re.compile(r"from +airflow\\.models\\.", re.IGNORECASE),
+ re.compile(r"import +airflow\\.models\\.", re.IGNORECASE),
+]
Review Comment:
Yeah - withh `ast` you could check if the imported classes derive from
BaseModel
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]