summaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/cors.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-11-03 15:45:35 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-11-03 16:52:44 -0700
commit91bd35a1ee0993126c369e39fbf8f81f775840ee (patch)
tree87e8bc6257359326f26102e7765e508d5529f0f5 /python/fatcat_web/cors.py
parent2e92e28df34d302fe02d1e1ff7169b7888648b9c (diff)
downloadfatcat-91bd35a1ee0993126c369e39fbf8f81f775840ee.tar.gz
fatcat-91bd35a1ee0993126c369e39fbf8f81f775840ee.zip
web: add type annotations
This commit does not include type fixes, only annotations. A small number of tuples were also converted to lists.
Diffstat (limited to 'python/fatcat_web/cors.py')
-rw-r--r--python/fatcat_web/cors.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/python/fatcat_web/cors.py b/python/fatcat_web/cors.py
index bb32f7c2..b0f33760 100644
--- a/python/fatcat_web/cors.py
+++ b/python/fatcat_web/cors.py
@@ -5,18 +5,19 @@ This snippet from: http://flask.pocoo.org/snippets/56/
from datetime import timedelta
from functools import update_wrapper
+from typing import Any
from flask import current_app, make_response, request
def crossdomain(
- origin=None,
- methods=None,
- headers=None,
- max_age=21600,
- attach_to_all=True,
- automatic_options=True,
-):
+ origin: Any = None,
+ methods: Any = None,
+ headers: Any = None,
+ max_age: Any = 21600,
+ attach_to_all: bool = True,
+ automatic_options: bool = True,
+) -> Any:
if methods is not None:
methods = ", ".join(sorted(x.upper() for x in methods))
if headers is not None and not isinstance(headers, str):
@@ -26,15 +27,15 @@ def crossdomain(
if isinstance(max_age, timedelta):
max_age = max_age.total_seconds()
- def get_methods():
+ def get_methods() -> Any:
if methods is not None:
return methods
options_resp = current_app.make_default_options_response()
return options_resp.headers["allow"]
- def decorator(f):
- def wrapped_function(*args, **kwargs):
+ def decorator(f: Any) -> Any:
+ def wrapped_function(*args, **kwargs) -> Any:
if automatic_options and request.method == "OPTIONS":
resp = current_app.make_default_options_response()
else: