Browse Source

Merge pull request #2342 from jrbaez01/issue/#2341-accept-one-default-argument

#2341: Accept default argument value when args lenght equal 1
pull/2053/merge
David Lord 8 years ago committed by GitHub
parent
commit
aeb82a404f
  1. 7
      flask/cli.py

7
flask/cli.py

@ -87,12 +87,15 @@ def call_factory(app_factory, script_info, arguments=()):
of arguments. Checks for the existence of a script_info argument and calls of arguments. Checks for the existence of a script_info argument and calls
the app_factory depending on that and the arguments provided. the app_factory depending on that and the arguments provided.
""" """
arg_names = getargspec(app_factory).args args_spec = getargspec(app_factory)
arg_names = args_spec.args
arg_defaults = args_spec.defaults
if 'script_info' in arg_names: if 'script_info' in arg_names:
return app_factory(*arguments, script_info=script_info) return app_factory(*arguments, script_info=script_info)
elif arguments: elif arguments:
return app_factory(*arguments) return app_factory(*arguments)
elif not arguments and len(arg_names) == 1: elif not arguments and len(arg_names) == 1 and arg_defaults is None:
return app_factory(script_info) return app_factory(script_info)
return app_factory() return app_factory()

Loading…
Cancel
Save