Skip to content

Commit d60b8d0

Browse files
Copilotredreceipt
andcommitted
Add type annotations to helper function
Co-authored-by: redreceipt <[email protected]>
1 parent ef353d8 commit d60b8d0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

app.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import re
22
import time
3-
from concurrent.futures import ThreadPoolExecutor, TimeoutError
3+
from concurrent.futures import Future, ThreadPoolExecutor, TimeoutError
44
from datetime import datetime
55
from functools import lru_cache
6-
from typing import TypedDict
6+
from typing import TypedDict, TypeVar
77

88
from flask import Flask, abort, render_template, request
99

@@ -123,7 +123,14 @@ def mmdd_filter(date_str: str) -> str:
123123
return date_str
124124

125125

126-
def get_future_result_with_timeout(future, default_value, timeout=INDEX_FUTURE_TIMEOUT):
126+
T = TypeVar('T')
127+
128+
129+
def get_future_result_with_timeout(
130+
future: Future[T],
131+
default_value: T,
132+
timeout: int = INDEX_FUTURE_TIMEOUT
133+
) -> T:
127134
"""
128135
Get result from a future with a timeout, returning a default value on timeout.
129136

0 commit comments

Comments
 (0)