summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-11-03 15:40:53 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-11-03 16:52:44 -0700
commit2e92e28df34d302fe02d1e1ff7169b7888648b9c (patch)
tree2f1f81831e35e3f44cf7dda323c2a30a71638b1a /python
parentb7750e4f8a3099cdd63d64506b92f26227cdcac9 (diff)
downloadfatcat-2e92e28df34d302fe02d1e1ff7169b7888648b9c.tar.gz
fatcat-2e92e28df34d302fe02d1e1ff7169b7888648b9c.zip
introduce 'AnyResponse' type for Flask views
Diffstat (limited to 'python')
-rw-r--r--python/fatcat_web/__init__.py1
-rw-r--r--python/fatcat_web/types.py14
2 files changed, 15 insertions, 0 deletions
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],
+]