From 2e92e28df34d302fe02d1e1ff7169b7888648b9c Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 3 Nov 2021 15:40:53 -0700 Subject: introduce 'AnyResponse' type for Flask views --- python/fatcat_web/__init__.py | 1 + python/fatcat_web/types.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 python/fatcat_web/types.py (limited to 'python/fatcat_web') diff --git a/python/fatcat_web/__init__.py b/python/fatcat_web/__init__.py index 4c08649e..0d3445ca 100644 --- a/python/fatcat_web/__init__.py +++ b/python/fatcat_web/__init__.py @@ -15,6 +15,7 @@ from flask_wtf.csrf import CSRFProtect from loginpass import GitHub, Gitlab, ORCiD, create_flask_blueprint from raven.contrib.flask import Sentry +from fatcat_web.types import AnyResponse from fatcat_web.web_config import Config toolbar = DebugToolbarExtension() diff --git a/python/fatcat_web/types.py b/python/fatcat_web/types.py new file mode 100644 index 00000000..f5182d71 --- /dev/null +++ b/python/fatcat_web/types.py @@ -0,0 +1,14 @@ +from typing import Any, Tuple, Union + +from flask import Response as FlaskResponse +from werkzeug.wrappers import Response as WerkzeugResponse + +# type to represent any of the used/plausible return types +AnyResponse = Union[ + FlaskResponse, + str, + Tuple[str, int], + WerkzeugResponse, + Tuple[FlaskResponse, int], + Tuple[WerkzeugResponse, int], +] -- cgit v1.2.3