This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new b85dd463bd5 Make wtforms optional for Providers Manager (#48094)
b85dd463bd5 is described below

commit b85dd463bd55f596f69a108118019ad987f09cd2
Author: Jarek Potiuk <[email protected]>
AuthorDate: Sat Mar 22 14:03:00 2025 +0100

    Make wtforms optional for Providers Manager (#48094)
---
 airflow-core/src/airflow/providers_manager.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/airflow-core/src/airflow/providers_manager.py 
b/airflow-core/src/airflow/providers_manager.py
index 16a8d67c0bd..20f6e492ee2 100644
--- a/airflow-core/src/airflow/providers_manager.py
+++ b/airflow-core/src/airflow/providers_manager.py
@@ -899,8 +899,6 @@ class ProvidersManager(LoggingMixin, metaclass=Singleton):
         :param package_name: provider package - only needed in case 
connection_type is missing
         : return
         """
-        from wtforms import BooleanField, IntegerField, PasswordField, 
StringField
-
         if connection_type is None and hook_class_name is None:
             raise ValueError("Either connection_type or hook_class_name must 
be set")
         if connection_type is not None and hook_class_name is not None:
@@ -919,18 +917,19 @@ class ProvidersManager(LoggingMixin, metaclass=Singleton):
                 raise ValueError(
                     f"Provider package name is not set when hook_class_name 
({hook_class_name}) is used"
                 )
-        allowed_field_classes = [IntegerField, PasswordField, StringField, 
BooleanField]
         hook_class: type[BaseHook] | None = _correctness_check(package_name, 
hook_class_name, provider_info)
         if hook_class is None:
             return None
         try:
+            from wtforms import BooleanField, IntegerField, PasswordField, 
StringField
+
+            allowed_field_classes = [IntegerField, PasswordField, StringField, 
BooleanField]
             module, class_name = hook_class_name.rsplit(".", maxsplit=1)
             # Do not use attr here. We want to check only direct class fields 
not those
             # inherited from parent hook. This way we add form fields only 
once for the whole
             # hierarchy and we add it only from the parent hook that provides 
those!
             if "get_connection_form_widgets" in hook_class.__dict__:
                 widgets = hook_class.get_connection_form_widgets()
-
                 if widgets:
                     for widget in widgets.values():
                         if widget.field_class not in allowed_field_classes:
@@ -948,8 +947,8 @@ class ProvidersManager(LoggingMixin, metaclass=Singleton):
                 if field_behaviours:
                     self._add_customized_fields(package_name, hook_class, 
field_behaviours)
         except ImportError as e:
-            if "No module named 'flask_appbuilder'" in e.msg:
-                log.warning(
+            if e.name in ["flask_appbuilder", "wtforms"]:
+                log.info(
                     "The hook_class '%s' is not fully initialized (UI widgets 
will be missing), because "
                     "the 'flask_appbuilder' package is not installed, however 
it is not required for "
                     "Airflow components to work",

Reply via email to