turbaszek commented on a change in pull request #7902: Enable celery command in any environment URL: https://github.com/apache/airflow/pull/7902#discussion_r399641898
########## File path: airflow/cli/cli_parser.py ########## @@ -55,6 +55,24 @@ def command(*args, **kwargs): return command +class DefaultHelpParser(argparse.ArgumentParser): + """CustomParser to display help message""" + + def _check_value(self, action, value): + """Override _check_value and check conditionally added command""" + executor = conf.get('core', 'EXECUTOR') + if value == 'celery' and executor != ExecutorLoader.CELERY_EXECUTOR: + message = f'celery command works only with CeleryExecutor, your current executor: {executor}' + raise ArgumentError(action, message) + + super()._check_value(action, value) + + def error(self, message): + """Override error and use print_instead of print_usage""" + self.print_help() + self.exit(2, '\n{} command error: {}, see help above.\n'.format(self.prog, message)) Review comment: Should we use f-string? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services