Skip to content

--help not working with classes #589

Description

@kakila

I cannot get --help to work with classes. I've read the (oldish) "current state" in #364 but it did not help.

Using the example from the documentation

importfireclassBuilding(object):
def__init__(self, name, stories=1):
self.name=nameself.stories=storiesdefclimb_stairs(self, stairs_per_story=10):
forstoryinrange(self.stories):
forstairinrange(1, stairs_per_story):
yieldstairyield'Phew!'yield'Done!'if__name__=='__main__':
fire.Fire(Building)

I get an error when I run the command suggested in the documentation:

$ python exmaple.py --name="Sherrerd Hall"
Traceback (most recent call last):
File "example.py", line 17, in<module>
fire.Fire(Building)
File "XXX/lib/python3.12/site-packages/fire/core.py", line 161, in Fire
_PrintResult(
File "XXX/lib/python3.12/site-packages/fire/core.py", line 272, in _PrintResult
help_text = helptext.HelpText(
^^^^^^^^^^^^^^^^^^
File "XXX/lib/python3.12/site-packages/fire/helptext.py", line 61, in HelpText
info = inspectutils.Info(component)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "XXX/lib/python3.12/site-packages/fire/inspectutils.py", line 259, in Info
inspector = oinspect.Inspector()
^^^^^^^^^^^^^^^^^^^^
TypeError: Inspector.__init__() missing 1 required keyword-only argument: 'theme_name'

If I run

python exmaple.py --name="Sherrerd Hall" -- help

I ge the same error; I was expecting to see the methods here. Even if I modified the call to any of

python example.py --name="Sherrerd Hall" --stories=3 -- --help
python example.py --name="Sherrerd Hall" --stories=3 climb_stairs -- --help
python example.py --name="Sherrerd Hall" --stories=3 climb_stairs 2 -- --help

I always get the same error as above.

If I call the method it works

$ python example.py --name="Sherrerd Hall" --stories=3 climb_stairs 2
1
Phew!
1
Phew!
1
Phew!
Done!

using
python 3.12.3
fire 0.7.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions