huggingface/smolagents · error · InterpreterError
super() argument 1 must be type
Error message
super() argument 1 must be type
What it means
super() was called with at least one argument, but the first argument is not a Python type (class). super(Cls, obj) requires the first argument to be a class object.
Source
Thrown at src/smolagents/local_python_executor.py:894
if keyword.arg is None:
# **kwargs unpacking
starred_dict = evaluate_ast(keyword.value, state, static_tools, custom_tools, authorized_imports)
if not isinstance(starred_dict, dict):
raise InterpreterError(f"Cannot unpack non-dict value in **kwargs: {type(starred_dict).__name__}")
kwargs.update(starred_dict)
else:
# Normal keyword argument
kwargs[keyword.arg] = evaluate_ast(keyword.value, state, static_tools, custom_tools, authorized_imports)
if func_name == "super":
if not args:
if "__class__" in state and "self" in state:
return super(state["__class__"], state["self"])
else:
raise InterpreterError("super() needs at least one argument")
cls = args[0]
if not isinstance(cls, type):
raise InterpreterError("super() argument 1 must be type")
if len(args) == 1:
return super(cls)
elif len(args) == 2:
instance = args[1]
return super(cls, instance)
else:
raise InterpreterError("super() takes at most 2 arguments")
elif func_name == "print":
state["_print_outputs"] += " ".join(map(str, args)) + "\n"
return None
else: # Assume it's a callable object
if (inspect.getmodule(func) == builtins) and inspect.isbuiltin(func) and (func not in static_tools.values()):
raise InterpreterError(
f"Invoking a builtin function that has not been explicitly added as a tool is not allowed ({func_name})."
)
if (
hasattr(func, "__name__")
and func.__name__.startswith("__")View on GitHub (pinned to 30bb116109)
Solutions
- Pass the class itself, not an instance or string: super(B, self)
- Check isinstance(first_arg, type) before calling
- Ensure the class name is not shadowed by a variable in state
Example fix
# before super(b, self).run() # b is an instance # after super(B, self).run() # B is the class
Defensive patterns
Strategy: type-guard
Validate before calling
cls = args[0]
assert isinstance(cls, type), f'super() arg1 must be a class, got {type(cls).__name__}'
super(cls, self) Type guard
def is_class(v) -> bool:
return isinstance(v, type) Try / catch
try:
evaluate_python(code, ...)
except InterpreterError as e:
if 'argument 1 must be type' in str(e):
# pass the class object instead of instance/string and retry Prevention
- Pass the class itself as super()'s first argument
- Don't shadow class names with variables
When it happens
Trigger: super(instance, self), super('ClassName', self), super(type(self), self) where type(self) evaluated to a non-type, or super(self.__class__.__name__, self).
Common situations: Agent code passes the instance instead of the class as first arg; passing the class name as a string; a variable shadowing the class name holding something else.
Related errors
- super() needs at least one argument
- super() takes at most 2 arguments
- Cannot unpack non-dict value in **kwargs: {type(starred_dict
- Invoking a builtin function that has not been explicitly add
- Forbidden call to dunder function: {func.__name__}
AI-assisted analysis of huggingface/smolagents@30bb116109 (2026-08-28).
Data as JSON: /api/errors/1d6b1ccb18a0e76c.
Report an issue: GitHub.