ashb commented on a change in pull request #12837:
URL: https://github.com/apache/airflow/pull/12837#discussion_r537129221



##########
File path: airflow/providers_manager.py
##########
@@ -209,22 +279,63 @@ def _add_hook(self, hook_class_name, provider_package) -> 
None:
                 e,
             )
             return
-        conn_type = getattr(hook_class, 'conn_type')
-        if not conn_type:
-            log.warning(
-                "The hook_class '%s' is missing connection_type attribute and 
cannot be registered",
-                hook_class,
-            )
+
+        conn_type: str = self._get_attr(hook_class, 'conn_type')
+        connection_id_attribute_name: str = self._get_attr(hook_class, 
'conn_name_attr')
+        hook_name: str = self._get_attr(hook_class, 'hook_name')
+
+        if not conn_type or not connection_id_attribute_name or not hook_name:
             return
-        connection_id_attribute_name = getattr(hook_class, 'conn_name_attr')
-        if not connection_id_attribute_name:
-            log.warning(
-                "The hook_class '%s' is missing conn_name_attr attribute and 
cannot be registered",
-                hook_class,
+
+        self._hooks_dict[conn_type] = HookInfo(
+            hook_class_name,
+            connection_id_attribute_name,
+            provider_package,
+            hook_name,
+        )
+
+    def _add_widgets(self, package_name: str, hook_class: type, widgets: 
Dict[str, Field]):
+        for field_name, field in widgets.items():
+            if not field_name.startswith("extra__"):
+                log.warning(
+                    "The field %s from class %s does not start with 'extra__'. 
Ignoring it.",
+                    field_name,
+                    hook_class.__name__,
+                )
+                continue
+            if field_name in self._connection_form_widgets:
+                log.warning(
+                    "The field %s from class %s has already been added by 
another provider. Ignoring it.",
+                    field_name,
+                    hook_class.__name__,
+                )
+                # In case of inherited hooks this might be happening several 
times
+                continue
+            self._connection_form_widgets[field_name] = 
ConnectionFormWidgetInfo(
+                hook_class.__name__, package_name, field
             )
-            return
 
-        self._hooks_dict[conn_type] = (hook_class_name, 
connection_id_attribute_name)
+    def _add_customized_fields(self, package_name: str, hook_class: type, 
customized_fields: Dict):

Review comment:
       ```suggestion
       def _add_field_behaviours(self, package_name: str, hook_class: type, 
customized_fields: Dict):
   ```




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to