Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raising FireError in __init__ is not handled properly #250

Open
mnowotnik opened this issue Apr 26, 2020 · 4 comments · May be fixed by #361
Open

Raising FireError in __init__ is not handled properly #250

mnowotnik opened this issue Apr 26, 2020 · 4 comments · May be fixed by #361

Comments

@mnowotnik
Copy link

In version 0.3.1 when user attempts to raise error in the __init__ method the effective error that gets printed is about missing self argument. Minimal example:

import fire
from fire.core import FireError
class Calc:

    def __init__(self):
        raise FireError('foo')

    def add(self):
        pass


if __name__ == "__main__":
    fire.Fire(Calc)
python calc.py add
ERROR: The function received no value for the required argument: self

When executed interactively, the error is correct:

>>>import calc; import fire
>>>fire.Fire(calc.Calc)
ERROR: foo
@iGieri
Copy link

iGieri commented May 3, 2020

I've the same error with the same version. I'm trying to debug core.py because the problem is in this file. I'll let you know if I found something.

@iGieri
Copy link

iGieri commented May 4, 2020

Today I've tried to create something like a filter in the _ParseArgs() function (core.py). This filter check if there is the keyword "self" in fn_args and the component is a class, so it remove "self" from fn_args and append it to fn_defaults (to do this I've converted fn_defaults to a list, I've appended "self" and I've reconverted it in a tuple), but this doesn't work. Tomorrow I'll try to find other solutions.

@dbieber
Copy link
Member

dbieber commented May 4, 2020

@joejoevictor is also taking a look at this

@aksg87
Copy link

aksg87 commented Sep 23, 2021

Any updates on this issue? cc: @joejoevictor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants