Skip to content
Myr

Merge pull request #4174 from na2shell/fix_4170

Before adoption: this commit came in with the history the project adopted, so no landing records it.

cli loader handles kwargs in app factory

authored by David Lord · committed by GitHub · parents c3f923d, 9f0da9b · Browse files · 3 files+26 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+26 added−12 removed

  • tests:+9 added−0 removed
  • other:+17 added−12 removed

3 files+26 added−12 removed

modified:src/flask/cli.py+15 added-12 removed
101 unmodified lines
102 DeprecationWarning,103 )104 kwargs["script_info"] = script_info105106 if (107 not args108 and len(sig.parameters) == 1109 and next(iter(sig.parameters.values())).default is inspect.Parameter.empty110 ):111 warnings.warn(112 "Script info is deprecated and will not be passed as the"113 " single argument to the app factory function in Flask"114 " 2.1.",115 DeprecationWarning,116 )117 args.append(script_info)106 if not args and len(sig.parameters) == 1:107 first_parameter = next(iter(sig.parameters.values()))108109 if (110 first_parameter.default is inspect.Parameter.empty111 # **kwargs is reported as an empty default, ignore it112 and first_parameter.kind is not inspect.Parameter.VAR_KEYWORD113 ):114 warnings.warn(115 "Script info is deprecated and will not be passed as the"116 " single argument to the app factory function in Flask"117 " 2.1.",118 DeprecationWarning,119 )120 args.append(script_info)121122 return app_factory(*args, **kwargs)123124125def _called_with_wrong_args(f):
873 unmodified lines
modified:tests/test_cli.py+9 added
74 unmodified lines
75 assert app.name == "appname"7677 class Module:78 @staticmethod79 def create_app(**kwargs):80 return Flask("appname")8182 app = find_best_app(script_info, Module)83 assert isinstance(app, Flask)84 assert app.name == "appname"8586 class Module:87 @staticmethod88 def create_app(foo):89 return Flask("appname")9091 with pytest.deprecated_call(match="Script info"):
597 unmodified lines
modified:CHANGES.rst+2 added
17 unmodified lines
18- ``jsonify`` handles ``decimal.Decimal`` by encoding to ``str``.19 :issue:`4157`20- Correctly handle raising deferred errors in CLI lazy loading.21 :issue:`4096`22- The CLI loader handles ``**kwargs`` in a ``create_app`` function.23 :issue:`4170`242526Version 2.0.127-------------
1154 unmodified lines