Repository navigation
Description
What is the issue?
Description
Since Dagger v0.20.7, @function-decorated methods inherited from parent classes are no longer visible in dagger functions output or dagger call --help. They were working correctly in v0.20.6.
Root Cause
PR #11803 ("feat(sdk/python): AST based analysis to introspect"), backported into v0.20.7, replaced the runtime-based introspection with a static AST parser.
Before (v0.20.6): The SDK used inspect.getmembers(cls) which traverses the Python MRO (Method Resolution Order), automatically discovering @function-decorated methods from parent classes.
After (v0.20.7): The new AST parser in sdk/python/src/dagger/mod/_analyzer/parser.py iterates only over node.body of the class definition. It does not traverse base classes to collect inherited @function methods.
The relevant code is in _extract_class_members (parser.py, line ~421):
for item in node.body:
...
elif isinstance(item, (ast.FunctionDef, ast.AsyncFunctionDef)):
if item.name == "create" and is_classmethod(item):
constructor = self._parse_constructor(item, file_path, node.name)
elif item.name == "__init__":
constructor = self._parse_init_constructor(item, file_path, node.name)
elif has_decorator(item, "function"):
func = self._parse_function(item, file_path, node.name)
functions.append(func)Only node.body is iterated — inherited methods are never seen. Note that constructor inheritance IS handled via _find_inherited_constructor, but @function inheritance is not.
Suggested Fix
In _extract_class_members (or a new helper similar to _find_inherited_constructor), traverse base classes in the AST and collect their @function-decorated methods. Something like:
def _find_inherited_functions(
self,
node: ast.ClassDef,
file_path: Path,
) -> list[FunctionMetadata]:
"""Collect @function-decorated methods from base classes."""
inherited = []
for base in node.bases:
base_name = None
if isinstance(base, ast.Name):
base_name = base.id
elif isinstance(base, ast.Attribute):
base_name = base.attr
if base_name is None:
continue
base_class = self._find_class_def(base_name)
if base_class is None:
continue
for item in base_class.body:
if (
isinstance(item, (ast.FunctionDef, ast.AsyncFunctionDef))
and has_decorator(item, "function")
):
func = self._parse_function(item, file_path, node.name)
inherited.append(func)
# Recurse into base class's own bases
inherited.extend(self._find_inherited_functions(base_class, file_path))
return inheritedThen call it from _parse_object_type and merge the results, skipping any function already overridden in the child class.
Related
- PR feat(sdk/python): AST based analysis to introspect #11803 — introduced the AST-based analyzer
- The old runtime code (_process_type using inspect.getmembers) correctly handled this via Python's MRO
Dagger version
dagger v0.20.7
Steps to reproduce
Parent class (in a shared library):
from dagger import function, object_type
@object_type
class PipelineModule(ABC):
@function
async def with_context(self, context_file: dagger.File) -> Self:
"""Inherited function that should be visible."""
...
@function
def with_component(self, name: str) -> Self:
"""Another inherited function that should be visible."""
...
Child class (module entrypoint):
from dagger import function, object_type
@object_type
class MyModule(PipelineModule):
@function
def my_own_function(self) -> str:
"""This function IS visible."""
...Expected output of dagger functions:
Expected output of dagger functions:
Name Description
my-own-function This function IS visible.
with-context Inherited function that should be visible.
with-component Another inherited function that should be visible.
Actual output of dagger functions (v0.20.7):
Name Description
my-own-function This function IS visible.
The inherited functions with-context and with-component are completely absent — not even listed as "skipped".
Log output
No response
Activity
eunomie commentedon May 5, 2026
Thanks for the report @gregoryboue
I opened a PR to fix it #13090
fix(sdk/python): discover @function methods inherited from base classes
eunomie commentedon May 5, 2026
@gregoryboue just to let you know that I'll close the PR mentioned above but the fix doesn't disappear it's now included in #13095 that covers more python AST related issues.
fix(sdk/python): discover @function methods inherited from base classes
fix(sdk/python): align AST module analyzer with typing.get_type_hints (…