google/python-fire · error · TypeError

Unsupported callable.

Error message

Unsupported callable.

What it means

GetFullArgSpec first tries inspect.signature on the callable; if that fails for any reason (ValueError for builtins/C extensions, AttributeError, exotic callables), Fire's Py3GetFullArgSpec re-raises TypeError('Unsupported callable.'). Fire cannot determine the argument spec needed for flag parsing.

Source

Thrown at fire/inspectutils.py:112

  This function instead skips bound args (self) and follows wrapped chains.

  Args:
    fn: The function or class of interest.
  Returns:
    An inspect.FullArgSpec namedtuple with the full arg spec of the function.
  """
  # pylint: disable=no-member

  try:
    sig = inspect._signature_from_callable(  # pylint: disable=protected-access  # type: ignore
        fn,
        skip_bound_arg=True,
        follow_wrapper_chains=True,
        sigcls=inspect.Signature)
  except Exception:
    # 'signature' can raise ValueError (most common), AttributeError, and
    # possibly others. We catch all exceptions here, and reraise a TypeError.
    raise TypeError('Unsupported callable.')

  args = []
  varargs = None
  varkw = None
  kwonlyargs = []
  defaults = ()
  annotations = {}
  defaults = ()
  kwdefaults = {}

  if sig.return_annotation is not sig.empty:
    annotations['return'] = sig.return_annotation

  for param in sig.parameters.values():
    kind = param.kind
    name = param.name

    # pylint: disable=protected-access

View on GitHub (pinned to 716bbc23d7)

Solutions

  1. Wrap the callable in a plain Python function with an explicit signature and fire that instead
  2. Use functools.wraps on decorators so __wrapped__/signature is preserved
  3. Fire a class or method defined in Python rather than the raw builtin
  4. Catch TypeError and fall back to a manual dispatcher

Example fix

// before
fire.Fire(os.stat)  # or another builtin / C function
// after
def stat_safe(path):
    return os.stat(path)
fire.Fire(stat_safe)
Defensive patterns

Strategy: fallback

Validate before calling

try:
    inspect.signature(fn)
except (TypeError, ValueError):
    raise TypeError(f'{fn!r} is not introspectable; wrap it in a Python function')

Type guard

def is_introspectable(fn) -> bool:
    try:
        inspect.signature(fn)
        return True
    except (TypeError, ValueError):
        return False

Try / catch

try:
    fire.Fire(fn)
except TypeError as e:
    if 'Unsupported callable' in str(e):
        fire.Fire(wrap_plain(fn))
    else:
        raise

Prevention

When it happens

Trigger: Firing a C builtin (e.g. fire.Fire(len) on some builds, fire.Fire(print) variants), ctypes functions, certain functools.partial/wrapper chains, or objects whose __call__ is unintrospectable.

Common situations: Exposing builtins or C extension functions as Fire commands; wrapping commands with non-standard decorators that hide the signature; platform version differences where signature support changed.

Related errors


AI-assisted analysis of google/python-fire@716bbc23d7 (2026-08-28). Data as JSON: /api/errors/4666ac5ff2480315. Report an issue: GitHub.