Nataneljpwd commented on code in PR #52700:
URL: https://github.com/apache/airflow/pull/52700#discussion_r2270881085
##########
providers/sftp/src/airflow/providers/sftp/hooks/sftp.py:
##########
@@ -49,22 +50,17 @@
from airflow.models.connection import Connection
-exclude_methods = [
- "__init__",
- "get_ui_field_behaviour",
- "get_conn",
- "close_conn",
- "get_managed_conn",
- "get_conn_count",
-] # exclude the methods which are not using the connection, so that we won't
create a
-# connection when not needed, i.e init
+def handle_connection_management(func):
+ CONNECTION_NOT_OPEN_EXCEPTION: ConnectionNotOpenedException =
ConnectionNotOpenedException(
+ "Connection not open, use with hook.get_managed_conn() Managed
Connection in order to create and open the connection"
+ )
-def handle_connection_management_decorator(func):
- def handle_connection_management(self, *args, **kwargs):
+ @functools.wraps(func)
+ def handle_connection_management_wrapper(self, *args, **kwargs):
Review Comment:
return is not callable but rather any, done
##########
providers/sftp/src/airflow/providers/sftp/hooks/sftp.py:
##########
@@ -49,22 +50,17 @@
from airflow.models.connection import Connection
-exclude_methods = [
- "__init__",
- "get_ui_field_behaviour",
- "get_conn",
- "close_conn",
- "get_managed_conn",
- "get_conn_count",
-] # exclude the methods which are not using the connection, so that we won't
create a
-# connection when not needed, i.e init
+def handle_connection_management(func):
+ CONNECTION_NOT_OPEN_EXCEPTION: ConnectionNotOpenedException =
ConnectionNotOpenedException(
+ "Connection not open, use with hook.get_managed_conn() Managed
Connection in order to create and open the connection"
+ )
-def handle_connection_management_decorator(func):
- def handle_connection_management(self, *args, **kwargs):
+ @functools.wraps(func)
+ def handle_connection_management_wrapper(self, *args, **kwargs):
if not self.managed_conn:
if self.conn is None:
- raise self.CONNECTION_NOT_OPEN_EXCEPTION
+ raise CONNECTION_NOT_OPEN_EXCEPTION
Review Comment:
done
--
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]