vincbeck commented on code in PR #56827:
URL: https://github.com/apache/airflow/pull/56827#discussion_r2445126953


##########
providers/fab/src/airflow/providers/fab/auth_manager/models/__init__.py:
##########
@@ -45,20 +43,21 @@
 from airflow.api_fastapi.auth.managers.models.base_user import BaseUser
 
 try:
-    from sqlalchemy.orm import mapped_column
+    from sqlalchemy.orm import mapped_column as _mapped_column
+
+    IS_SQLALCHEMY_2 = True
 except ImportError:
     # fallback for SQLAlchemy < 2.0
-    def mapped_column(*args, **kwargs):
+    IS_SQLALCHEMY_2 = False
+
+    def _fallback_mapped_column(*args, **kwargs):
         from sqlalchemy import Column
 
         return Column(*args, **kwargs)
 
 
-if TYPE_CHECKING:
-    try:
-        from sqlalchemy import Identity
-    except Exception:
-        Identity = None
+mapped_column = _mapped_column if IS_SQLALCHEMY_2 else _fallback_mapped_column

Review Comment:
   Why this change?



##########
providers/fab/tests/unit/fab/auth_manager/models/test_user_model.py:
##########
@@ -35,7 +35,7 @@ def test_get_id_returns_str(user_id: int | str, expected_id: 
str) -> None:
     Ensure get_id() always returns a string representation of the id.
     """
     user = User()
-    user.id = user_id
+    user.id = user_id  # type: ignore[assignment] # id can be int or str for 
this test

Review Comment:
   We should modify the test to only use int since the model only accepts int



-- 
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]

Reply via email to