autoprogram
autoprogram copied to clipboard
argparse after `__name__ == "__main__"`
Dear autoprogram team,
If I have a code like this:
if __name__ == "__main__":
logger.setLevel("DEBUG")
parser = argparse.ArgumentParser(
description="""random"""
)
then the autoprogram is unable to see the parser object for that specific file. Moving parser up before the if works, but require all the add_argument to be above the if __name__ == "__main__".
I usually declare the parser only if this is executed as a script or with the -m option of python, and tend to avoid global objects otherwise.
Is there a way to make it work like this?
Thank you,
I have the same problem.
@raffienficiaud did you get any further ideas how to solve this?
@LongnoseRob sorry no, could not find a way to work around it. It should not be too difficult though, the code for getting the parser object seems to be this one but one needs to dig in.