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



##########
File path: airflow/providers_manager.py
##########
@@ -60,38 +63,29 @@ def __new__(cls):
         return cls._instance
 
     def __init__(self):
-        # Keeps list of providers keyed by module name and value is Tuple: 
version, provider_info
+        # Keeps dict of providers keyed by module name and value is Tuple: 
version, provider_info
         self._provider_dict: Dict[str, Tuple[str, Dict]] = {}
+        # Keeps dict of hooks keyed by connection type and value is
+        # Tuple: connection class, connection_id_attribute_name
+        self._hooks_dict: Dict[str, Tuple[str, str]] = {}
         self._validator = _create_validator()
         # Local source folders are loaded first. They should take precedence 
over the package ones for
         # Development purpose. In production provider.yaml files are not 
present in the 'airflow" directory
         # So there is no risk we are going to override package provider 
accidentally. This can only happen
         # in case of local development
         self._discover_all_airflow_builtin_providers_from_local_sources()
         self._discover_all_providers_from_packages()
-        self._sort_provider_dictionary()
-
-    def _sort_provider_dictionary(self):
-        """
-        Sort provider_dictionary using OrderedDict.
-
-        The dictionary gets sorted so that when you iterate through it, the 
providers are by
-        default returned in alphabetical order.
-        """
-        sorted_dict = OrderedDict()
-        for provider_name in sorted(self._provider_dict.keys()):
-            sorted_dict[provider_name] = self._provider_dict[provider_name]
-        self._provider_dict = sorted_dict
+        self._discover_hooks()
+        self._provider_dict = OrderedDict(sorted(self.providers.items()))
+        self._hooks_dict = OrderedDict(sorted(self.providers.items()))
 
     def _discover_all_providers_from_packages(self) -> None:
         """
         Discovers all providers by scanning packages installed. The list of 
providers should be returned
         via the 'apache_airflow_provider' entrypoint as a dictionary 
conforming to the
         'airflow/provider.yaml.schema.json' schema.
         """
-        from airflow.plugins_manager import entry_points_with_dist

Review comment:
       An import in a function should never be able to cause a circular import 
I thought, unless this function is also called from a top level somewhere.
   
   That's why I put the import here, not at the top level.




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