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

Exit code 1 when using a @call_parse CLI with a return #442

Open
pwdemars opened this issue Jul 27, 2022 · 3 comments
Open

Exit code 1 when using a @call_parse CLI with a return #442

pwdemars opened this issue Jul 27, 2022 · 3 comments

Comments

@pwdemars
Copy link

Using fastcore 1.5.10 I have been noticing some of my Github workflows failing with "Process completed with exit code 1" and no other error messages.

After playing around it seems that @call_parse decorated functions which return something cause this behaviour. A minimal example:

@call_parse
def func1():
    x = 1
    return x

@call_parse
def func2():
    x = 1

Now, at the command line:

> func1
> echo $?
1

> func2 
> echo $?
0

That is, the first function fails while the second works fine. Is this intended? In my experience it can be useful to double up my CLI with general usage functions; currently I will need to use dedicated CLI functions which are not usable elsewhere in my code.

Thanks a lot in advance!

@jph00
Copy link
Contributor

jph00 commented Aug 5, 2022

Yes it is intended, but I can see your argument that it's perhaps more annoying that helpful!... I guess if we removed it the alternative would be to use an Exception to create a non-zero exit code?

@Taytay
Copy link

Taytay commented Jun 15, 2023

I think an exception to create non-zero would be great.
I just got bit by this. I say that because when I run the function in a python file, I want it to return something helpful. When I run it as a script, I'm fine for it not to return anything...

@jph00
Copy link
Contributor

jph00 commented Jun 15, 2023

Fair enough! A PR for this functionality would be welcome. :)

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

No branches or pull requests

3 participants