Refine caching in parser.
@@ -31,9 +31,7 @@ def full_parser():
"""
global _full_parser
- if _full_parser:
- return _full_parser
-
+ if not _full_parser:
luigi_parser = luigi.cmdline_parser.CmdlineParser.get_instance()
if not luigi_parser:
return None
@@ -42,21 +40,19 @@ def full_parser():
root_task = luigi_parser.known_args.root_task
_full_parser = luigi_parser._build_parser(root_task)
- logger.debug("build full luigi argument parser")
+ logger.debug("built full luigi argument parser")
return _full_parser
def root_task_parser():
"""
- Returns a new *ArgumentParser* instance that only contains paremeter actions of the root task.
+ Returns a new *ArgumentParser* instance that only contains parameter actions of the root task.
The returned instance is cached.
"""
global _root_task_parser
- if _root_task_parser:
- return _root_task_parser
-
+ if not _root_task_parser:
luigi_parser = luigi.cmdline_parser.CmdlineParser.get_instance()
if not luigi_parser:
return None
@@ -75,7 +71,7 @@ def root_task_parser():
if not action.option_strings or action.dest in root_dests:
_root_task_parser._add_action(action)
- logger.debug("build luigi argument parser for root task {}".format(root_task))
+ logger.debug("built luigi argument parser for root task {}".format(root_task))
return _root_task_parser
@@ -92,9 +88,7 @@ def global_cmdline_args():
"""
global _global_cmdline_args
- if _global_cmdline_args:
- return _global_cmdline_args
-
+ if not _global_cmdline_args:
luigi_parser = luigi.cmdline_parser.CmdlineParser.get_instance()
if not luigi_parser:
return None
@@ -117,9 +111,7 @@ def global_cmdline_values():
"""
global _global_cmdline_values
- if _global_cmdline_values:
- return _global_cmdline_values
-
+ if not _global_cmdline_values:
luigi_parser = luigi.cmdline_parser.CmdlineParser.get_instance()
if not luigi_parser:
return None
