cli loader handles kwargs in app factory
This commit is contained in:
parent
c3f923d0e0
commit
9f0da9b770
3 changed files with 26 additions and 12 deletions
|
|
@ -103,18 +103,21 @@ def call_factory(script_info, app_factory, args=None, kwargs=None):
|
|||
)
|
||||
kwargs["script_info"] = script_info
|
||||
|
||||
if (
|
||||
not args
|
||||
and len(sig.parameters) == 1
|
||||
and next(iter(sig.parameters.values())).default is inspect.Parameter.empty
|
||||
):
|
||||
warnings.warn(
|
||||
"Script info is deprecated and will not be passed as the"
|
||||
" single argument to the app factory function in Flask"
|
||||
" 2.1.",
|
||||
DeprecationWarning,
|
||||
)
|
||||
args.append(script_info)
|
||||
if not args and len(sig.parameters) == 1:
|
||||
first_parameter = next(iter(sig.parameters.values()))
|
||||
|
||||
if (
|
||||
first_parameter.default is inspect.Parameter.empty
|
||||
# **kwargs is reported as an empty default, ignore it
|
||||
and first_parameter.kind is not inspect.Parameter.VAR_KEYWORD
|
||||
):
|
||||
warnings.warn(
|
||||
"Script info is deprecated and will not be passed as the"
|
||||
" single argument to the app factory function in Flask"
|
||||
" 2.1.",
|
||||
DeprecationWarning,
|
||||
)
|
||||
args.append(script_info)
|
||||
|
||||
return app_factory(*args, **kwargs)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue