From 91bd35a1ee0993126c369e39fbf8f81f775840ee Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 3 Nov 2021 15:45:35 -0700 Subject: web: add type annotations This commit does not include type fixes, only annotations. A small number of tuples were also converted to lists. --- python/fatcat_web/cors.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'python/fatcat_web/cors.py') 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: -- cgit v1.2.3