|
38 | 38 | _insecure_views = ['main.login', 'main.select_logo', 'static'] |
39 | 39 |
|
40 | 40 |
|
41 | | -def create_app(config): |
42 | | - # type: (SDConfig) -> Flask |
| 41 | +def create_app(config: 'SDConfig') -> Flask: |
43 | 42 | app = Flask(__name__, |
44 | 43 | template_folder=config.JOURNALIST_TEMPLATES_DIR, |
45 | 44 | static_folder=path.join(config.SECUREDROP_ROOT, 'static')) |
@@ -82,16 +81,16 @@ def create_app(config): |
82 | 81 | ) |
83 | 82 |
|
84 | 83 | @app.errorhandler(CSRFError) |
85 | | - def handle_csrf_error(e): |
86 | | - # type: (CSRFError) -> Response |
| 84 | + def handle_csrf_error(e: CSRFError) -> 'Response': |
87 | 85 | # render the message first to ensure it's localized. |
88 | 86 | msg = gettext('You have been logged out due to inactivity') |
89 | 87 | session.clear() |
90 | 88 | flash(msg, 'error') |
91 | 89 | return redirect(url_for('main.login')) |
92 | 90 |
|
93 | | - def _handle_http_exception(error): |
94 | | - # type: (HTTPException) -> Tuple[Union[Response, str], Optional[int]] |
| 91 | + def _handle_http_exception( |
| 92 | + error: 'HTTPException' |
| 93 | + ) -> 'Tuple[Union[Response, str], Optional[int]]': |
95 | 94 | # Workaround for no blueprint-level 404/5 error handlers, see: |
96 | 95 | # https://github.com/pallets/flask/issues/503#issuecomment-71383286 |
97 | 96 | handler = list(app.error_handler_spec['api'][error.code].values())[0] |
@@ -129,8 +128,7 @@ def load_instance_config(): |
129 | 128 | app.instance_config = InstanceConfig.get_current() |
130 | 129 |
|
131 | 130 | @app.before_request |
132 | | - def setup_g(): |
133 | | - # type: () -> Optional[Response] |
| 131 | + def setup_g() -> 'Optional[Response]': |
134 | 132 | """Store commonly used values in Flask's special g object""" |
135 | 133 | if 'expires' in session and datetime.utcnow() >= session['expires']: |
136 | 134 | session.clear() |
|
0 commit comments