Skip to content

Commit 787301e

Browse files
committed
fix mypy functions/__init__.py
1 parent 97df9da commit 787301e

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
1-
def tr_link(app, need, needs, test_option, target_option, *args, **kwargs):
1+
from typing import Dict, List, Union
2+
3+
4+
def tr_link(
5+
app: object, # Typed as object since the exact type is unknown
6+
need: Dict[
7+
str, Union[str, int]
8+
], # Keys are strings, values are strings or integers
9+
needs: Dict[str, Dict[str, Union[str, int]]], # Nested dictionary
10+
test_option: str,
11+
target_option: str,
12+
*args: object,
13+
**kwargs: object,
14+
) -> List[str]:
215
if test_option not in need:
3-
return ""
16+
return []
417

518
# Allow for multiple values in option
6-
test_opt_values = need[test_option].split(",")
19+
test_opt_values: List[str] = str(need[test_option]).split(",")
720

8-
links = []
21+
links: List[str] = []
922
for need_target in needs.values():
1023
if target_option not in need_target:
1124
continue
1225
for test_opt_raw in test_opt_values:
13-
test_opt = test_opt_raw.strip()
26+
test_opt: str = test_opt_raw.strip()
1427
if (
1528
test_opt == need_target[target_option]
1629
and test_opt is not None
1730
and len(test_opt) > 0 # fmt: skip
1831
):
19-
links.append(need_target["id"])
32+
links.append(str(need_target.get("id", "")))
2033

2134
return links

0 commit comments

Comments
 (0)