Python Fire

raw JSON →
0.1.0 verified Fri May 01 auth: no python

Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object. Current version is 0.1.0. Release cadence is irregular; last release was in 2018.

pip install python-fire
error 'Fire' object is not callable
cause Importing Fire incorrectly as a class or attribute from fire module.
fix
Use 'import fire' then call 'fire.Fire(function)'.
error TypeError: 'str' object is not callable
cause Fire may interpret a class's __init__ as the default command but return a string when instantiated, causing confusion.
fix
Use classes with Fire by calling fire.Fire(ClassName) and ensure methods return strings or use --help.
gotcha Fire uses argument parsing that may conflict with argparse or click if used in the same script. Avoid mixing libraries that parse sys.argv.
fix Use Fire alone for CLI entry points, or call fire.Fire() only when __name__ == '__main__'.
gotcha Fire's type inference is limited; it may not properly handle complex types like custom classes or nested objects. It works best with simple types.
fix Provide explicit help strings or use docstrings to guide parsing.
deprecated Python Fire 0.1.0 is very old (2018). It has known bugs and no active maintenance. Consider alternatives like Typer or Click.
fix Migrate to Typer (pip install typer) for modern CLI generation.

Basic CLI generation from a function.

import fire

def hello(name="World"):
  return "Hello %s!" % name

if __name__ == '__main__':
  fire.Fire(hello)