dabla commented on code in PR #73288:
URL: https://github.com/apache/airflow/pull/73288#discussion_r4052851732


##########
providers/sftp/tests/unit/sftp/pools/test_sftp.py:
##########
@@ -88,6 +89,71 @@ async def 
test_get_sftp_client_marks_connection_faulty_on_exception(self, sftp_h
 
         assert any(call.kwargs.get("faulty") is True for call in 
release_spy.call_args_list)
 
+    @pytest.mark.parametrize(
+        ("exc", "expected"),
+        [
+            pytest.param(asyncssh.SFTPNoSuchFile("missing"), False, 
id="no-such-file"),
+            pytest.param(asyncssh.SFTPPermissionDenied("denied"), False, 
id="permission-denied"),
+            pytest.param(asyncssh.SFTPFailure("failure"), False, id="failure"),
+            pytest.param(asyncssh.SFTPOpUnsupported("unsupported"), False, 
id="op-unsupported"),
+            pytest.param(asyncssh.SFTPConnectionLost("lost"), True, 
id="connection-lost"),
+            pytest.param(asyncssh.SFTPNoConnection("no connection"), True, 
id="no-connection"),
+            pytest.param(asyncssh.SFTPBadMessage("bad message"), True, 
id="bad-message"),
+            pytest.param(ValueError("boom"), True, id="not-an-sftp-error"),

Review Comment:
   Same here, this is just a nit like previous comment, I would opt to import 
those exceptions from asyncssh.



##########
providers/sftp/src/airflow/providers/sftp/pools/sftp.py:
##########
@@ -21,14 +21,31 @@
 from contextlib import asynccontextmanager, suppress
 from dataclasses import dataclass, field
 from threading import Lock
-from typing import TYPE_CHECKING
 from weakref import WeakKeyDictionary
 
+import asyncssh
+
 from airflow.providers.sftp.hooks.sftp import SFTPHookAsync
 from airflow.utils.log.logging_mixin import LoggingMixin
 
-if TYPE_CHECKING:
-    import asyncssh
+#: SFTP status codes that report a broken or desynchronised transport.
+_TRANSPORT_SFTP_ERRORS: tuple[type[asyncssh.SFTPError], ...] = (
+    asyncssh.SFTPNoConnection,
+    asyncssh.SFTPConnectionLost,
+    asyncssh.SFTPBadMessage,

Review Comment:
   I would opt to import those exceptions from asyncssh:
   
   `from asyncssh import SFTPBadMessage, SFTPConnectionLost, SFTPNoConnection`



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