uranusjr commented on code in PR #60065:
URL: https://github.com/apache/airflow/pull/60065#discussion_r2667841596


##########
shared/module_loading/src/airflow_shared/module_loading/__init__.py:
##########
@@ -63,10 +63,13 @@ def import_string(dotted_path: str):
         raise ImportError(f'Module "{module_path}" does not define a 
"{class_name}" attribute/class')
 
 
-def qualname(o: object | Callable) -> str:
-    """Convert an attribute/class/function to a string importable by 
``import_string``."""
-    if callable(o) and hasattr(o, "__module__") and hasattr(o, "__name__"):
-        return f"{o.__module__}.{o.__name__}"
+def qualname(o: object | Callable, use_qualname: bool = False) -> str:
+    """Convert an attribute/class/callable to a string importable by 
``import_string``."""
+    if callable(o) and hasattr(o, "__module__"):
+        if use_qualname and hasattr(o, "__qualname__"):
+            return f"{o.__module__}.{o.__qualname__}"
+        if hasattr(o, "__name__"):
+            return f"{o.__module__}.{o.__name__}"

Review Comment:
   Let’s just always use qualname. In cases where this matters (when the string 
is loaded back by `import_string`), `__name__` would not work anyway.



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