Skip to content
Myr

Remove unnecessary checks and reformat NoAppException messages

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

authored by Hendrik Makait · committed by Hendrik Makait · parent ced719e · Browse files · 1 file+13 added−11 removed
This commit

State

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

Diff stats

1 file+13 added−11 removed

  • other:+13 added−11 removed

1 file+13 added−11 removed

modified:flask/cli.py+13 added-11 removed
35 unmodified lines
3637 # Search for the most common names first.38 for attr_name in 'app', 'application':39 app = getattr(module, attr_name, None)40 if app is not None and isinstance(app, Flask):40 if isinstance(app, Flask):41 return app4243 # Otherwise find the only object that is a Flask instance.44 matches = [v for k, v in iteritems(module.__dict__)
4 unmodified lines
4950 # Search for app factory callables.51 for attr_name in 'create_app', 'make_app':52 app_factory = getattr(module, attr_name, None)53 if app_factory is not None and callable(app_factory):53 if callable(app_factory):54 try:55 app = app_factory()56 if app is not None and isinstance(app, Flask):56 if isinstance(app, Flask):57 return app58 except TypeError:59 raise NoAppException('Auto-detected "%s()" in module "%s", '60 'but could not call it without '61 'specifying arguments.'62 % (attr_name, module.__name__))59 raise NoAppException(60 'Auto-detected "{callable}()" in module "{module}", but '61 'could not call it without specifying arguments.'62 .format(callable=attr_name,63 module=module.__name__))6464 raise NoAppException('Failed to find application in module "%s". Are '65 'you sure it contains a Flask application? Maybe '66 'you wrapped it in a WSGI middleware or you are '67 'using a factory function.' % module.__name__)65 raise NoAppException(66 'Failed to find application in module "{module}". Are you sure '67 'it contains a Flask application? Maybe you wrapped it in a WSGI '68 'middleware or you are using a factory function.'69 .format(module=module.__name__))707172def prepare_exec_for_file(filename):73 """Given a filename this will try to calculate the python path, add it
524 unmodified lines